@Override
	public Object parse(JSONObject json) {
		Route route = null;
		// Tranform the string into a json object
		JSONArray jsonRoutes = json.getJSONArray("routes");
		// Get the route object
		if (jsonRoutes.length() > 0) {
			route = new Route();
			JSONObject jsonRoute = jsonRoutes.getJSONObject(0);
			// Get the leg, only one leg as we don't support waypoints
			JSONObject leg = jsonRoute.getJSONArray("legs").getJSONObject(0);
			// Get the steps for this leg
			JSONArray steps = leg.getJSONArray("steps");
			// Number of steps for use in for loop
			int numSteps = steps.length();
			// Get the total length of the route.
			route.setLength(leg.getJSONObject("distance").getInt("value"));
			// Loop through the steps, creating a segment for each one and decoding any polylines found as we go to
			// add to the route object's map array. Using an explicit for loop because it is faster!
			for (int i = 0; i < numSteps; i++) {
				// Get the individual step
				JSONObject step = steps.getJSONObject(i);
				// Retrieve & decode this segment's polyline and add it to the route.
				route.addPoints(decodePolyLine(step.getJSONObject("polyline").getString("points")));
			}
		}
		return route;
	}
@ Override public Object parse ( JSONObject json ) { Route route = null ; JSONArray jsonRoutes = json . getJSONArray ( "routes" ) ; if ( jsonRoutes . length ( ) > 0 ) { route = new Route ( ) ; JSONObject jsonRoute = jsonRoutes . getJSONObject ( 0 ) ; JSONObject leg = jsonRoute . getJSONArray ( "legs" ) . getJSONObject ( 0 ) ; JSONArray steps = leg . getJSONArray ( "steps" ) ; int numSteps = steps . length ( ) ; route . setLength ( leg . getJSONObject ( "distance" ) . getInt ( "value" ) ) ; for ( int i = 0 ; i < numSteps ; i ++ ) { JSONObject step = steps . getJSONObject ( i ) ; route . addPoints ( decodePolyLine ( step . getJSONObject ( "polyline" ) . getString ( "points" ) ) ) ; } } return route ; }
@see JsonParser#parse(java.lang.Object)