title: How to parse "steps" from the google directions API to java (android)
body: <p>I'm a complete beginner, especially when is comes to JSON parsing.  </p>
  
  <p>I've been using the google directions API 
  to make a basic navigation app that draws a route from two locations, which is all great. However after trying for hours to parse the "steps" from the API, I still can't make it work.</p>
  
  <p>I've used this example <a href="https://github.com/hiepxuan2008/GoogleMapDirectionSimple" rel="nofollow noreferrer">https://github.com/hiepxuan2008/GoogleMapDirectionSimple</a>
  to parse the JSON to draw the route. </p>
  
  <p>This is done in the following code. (full code on github "Directionfinder.java")</p>
  
  <pre><code>private void parseJSon(String data) throws JSONException {
      if (data == null)
          return;
  
      List&lt;Route&gt; routes = new ArrayList&lt;Route&gt;();
      JSONObject jsonData = new JSONObject(data);
      JSONArray jsonRoutes = jsonData.getJSONArray("routes");
      for (int i = 0; i &lt; jsonRoutes.length(); i++) {
          JSONObject jsonRoute = jsonRoutes.getJSONObject(i);
          Route route = new Route();
  
          JSONObject overview_polylineJson = jsonRoute.getJSONObject("overview_polyline");
          JSONArray jsonLegs = jsonRoute.getJSONArray("legs");
          JSONObject jsonLeg = jsonLegs.getJSONObject(0);
          JSONObject jsonDistance = jsonLeg.getJSONObject("distance");
          JSONObject jsonDuration = jsonLeg.getJSONObject("duration");
          JSONObject jsonEndLocation = jsonLeg.getJSONObject("end_location");
          JSONObject jsonStartLocation = jsonLeg.getJSONObject("start_location");
  
          route.distance = new Distance(jsonDistance.getString("text"), jsonDistance.getInt("value"));
          route.duration = new Duration(jsonDuration.getString("text"), jsonDuration.getInt("value"));
          route.endAddress = jsonLeg.getString("end_address");
          route.startAddress = jsonLeg.getString("start_address");
          route.startLocation = new LatLng(jsonStartLocation.getDouble("lat"), jsonStartLocation.getDouble("lng"));
          route.endLocation = new LatLng(jsonEndLocation.getDouble("lat"), jsonEndLocation.getDouble("lng"));
          route.points = decodePolyLine(overview_polylineJson.getString("points"));
  
          routes.add(route);
      }
  
      listener.onDirectionFinderSuccess(routes);
  }
  </code></pre>
  
  <p>Heres how the JSON typically looks. <a href="http://pastebin.com/czYkBWWU" rel="nofollow noreferrer">http://pastebin.com/czYkBWWU</a></p>
  
  <p>I need to parse "maneuver", "start_location", "distance", "start_location and the position from every step of a given route. </p>
  
  <p>It seems fairly easy to parse this, but I just can't figure out how.</p>
  
  <p>Any help will be greatly appreciated!</p>