title: JSON parsing from google direction API
body: <p><strong>I want to parse step by step direction from start point to end point on google map . for parsing i use the following link :</strong></p>
  
  <p><a href="https://maps.googleapis.com/maps/api/directions/json?origin=23.052566,%2072.565956&amp;destination=24.052566,75.565956&amp;sensor=false" rel="nofollow">Google Map Direction API</a></p>
  
  <p>at that link i want to parse "maneuver"  json array .</p>
  
  <p><strong>how can I get step by step  direction from that json file and where should I change in to my code ??</strong>
  thanx in advance ...
  apart from this my code is display below :</p>
  
  <pre><code>public class **DirectionsJSONParser** {
  
      /** Receives a JSONObject and returns a list of lists containing latitude and longitude */
      public List&lt;List&lt;HashMap&lt;String,String&gt;&gt;&gt; parse(JSONObject jObject){
  
          List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; routes = new ArrayList&lt;List&lt;HashMap&lt;String,String&gt;&gt;&gt;() ;
          JSONArray jRoutes = null;
          JSONArray jLegs = null;
          JSONArray jSteps = null;    
  
          try {           
  
              jRoutes = jObject.getJSONArray("routes");
  
              /** Traversing all routes */
              for(int i=0;i&lt;jRoutes.length();i++){            
                  jLegs = ( (JSONObject)jRoutes.get(i)).getJSONArray("legs");
                  List path = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
                  /** Traversing all legs */
                  for(int j=0;j&lt;jLegs.length();j++){
                      jSteps = ( (JSONObject)jLegs.get(j)).getJSONArray("steps");
  
                      /** Traversing all steps */
                      for(int k=0;k&lt;jSteps.length();k++){
                          String polyline = "";
                          polyline = (String)((JSONObject)((JSONObject)jSteps.get(k)).get("polyline")).get("points");
                          List&lt;LatLng&gt; list = decodePoly(polyline);
  
                          /** Traversing all points */
                          for(int l=0;l&lt;list.size();l++){
                              HashMap&lt;String, String&gt; hm = new HashMap&lt;String, String&gt;();
                              hm.put("lat", Double.toString(((LatLng)list.get(l)).latitude) );
                              hm.put("lng", Double.toString(((LatLng)list.get(l)).longitude) );
                              path.add(hm);                       
                          }                               
                      }
                      routes.add(path);
                  }
              }
  
          } catch (JSONException e) {         
              e.printStackTrace();
          }catch (Exception e){           
          }
  
  
          return routes;
      }   
  
  
  
      private List&lt;LatLng&gt; **decodePoly**(String encoded) {
  
          List&lt;LatLng&gt; poly = new ArrayList&lt;LatLng&gt;();
          int index = 0, len = encoded.length();
          int lat = 0, lng = 0;
  
          while (index &lt; len) {
              int b, shift = 0, result = 0;
              do {
                  b = encoded.charAt(index++) - 63;
                  result |= (b &amp; 0x1f) &lt;&lt; shift;
                  shift += 5;
              } while (b &gt;= 0x20);
              int dlat = ((result &amp; 1) != 0 ? ~(result &gt;&gt; 1) : (result &gt;&gt; 1));
              lat += dlat;
  
              shift = 0;
              result = 0;
              do {
                  b = encoded.charAt(index++) - 63;
                  result |= (b &amp; 0x1f) &lt;&lt; shift;
                  shift += 5;
              } while (b &gt;= 0x20);
              int dlng = ((result &amp; 1) != 0 ? ~(result &gt;&gt; 1) : (result &gt;&gt; 1));
              lng += dlng;
  
              LatLng p = new LatLng((((double) lat / 1E5)),
                      (((double) lng / 1E5)));
              poly.add(p);
          }
  
          return poly;
      }
  }
  </code></pre>