title: Drilling down into JSON Data Arrays Android
body: <p>I am having an issue when trying to drill down further into json data to pull out specific key/value pairs. I am simply trying to pull the longtitude/latitude which I figured is a sub array of location which is a sub array of geometry. 
  My JSON:</p>
  
  <pre><code>results": [
      {
        "address_components": [
          {
            "long_name": "56",
            "short_name": "56",
            "types": [
              "street_number"
            ]
          },
          {
            "long_name": "Rosario Drive",
            "short_name": "Rosario Dr",
            "types": [
              "route"
            ]
          },
          {
            "long_name": "Waterbury",
            "short_name": "Waterbury",
            "types": [
              "locality",
              "political"
            ]
          },
          {
            "long_name": "New Haven",
            "short_name": "New Haven",
            "types": [
              "administrative_area_level_2",
              "political"
            ]
          },
          {
            "long_name": "Connecticut",
            "short_name": "CT",
            "types": [
              "administrative_area_level_1",
              "political"
            ]
          },
          {
            "long_name": "United States",
            "short_name": "US",
            "types": [
              "country",
              "political"
            ]
          },
          {
            "long_name": "06708",
            "short_name": "06708",
            "types": [
              "postal_code"
            ]
          }
        ],
        "formatted_address": "56 Rosario Drive, Waterbury, CT 06708, USA",
        "geometry": {
          "bounds": {
            "northeast": {
              "lat": 41.5291983,
              "lng": -73.0523455
            },
            "southwest": {
              "lat": 41.5291845,
              "lng": -73.0523456
            }
          },
          "location": {
            "lat": 41.5291845,
            "lng": -73.0523456
          },
          "location_type": "RANGE_INTERPOLATED",
          "viewport": {
            "northeast": {
              "lat": 41.5305403802915,
              "lng": -73.05099656970849
            },
            "southwest": {
              "lat": 41.5278424197085,
              "lng": -73.05369453029151
            }
          }
        },
        "types": [
          "street_address"
        ]
      },
      {
        "address_components": [
          {
            "long_name": "56",
            "short_name": "56",
            "types": [
              "street_number"
            ]
          },
          {
            "long_name": "Rosario Drive",
            "short_name": "Rosario Dr",
            "types": [
              "route"
            ]
          },
          {
            "long_name": "Woodbridge",
            "short_name": "Woodbridge",
            "types": [
              "sublocality",
              "political"
            ]
          },
          {
            "long_name": "Vaughan",
            "short_name": "Vaughan",
            "types": [
              "locality",
              "political"
            ]
          },
          {
            "long_name": "York Regional Municipality",
            "short_name": "York Regional Municipality",
            "types": [
              "administrative_area_level_2",
              "political"
            ]
          },
          {
            "long_name": "Ontario",
            "short_name": "ON",
            "types": [
              "administrative_area_level_1",
              "political"
            ]
          },
          {
            "long_name": "Canada",
            "short_name": "CA",
            "types": [
              "country",
              "political"
            ]
          },
          {
            "long_name": "L4H",
            "short_name": "L4H",
            "types": [
              "postal_code_prefix",
              "postal_code"
            ]
          }
        ],
        "formatted_address": "56 Rosario Drive, Vaughan, ON L4H, Canada",
        "geometry": {
          "bounds": {
            "northeast": {
              "lat": 43.8324404,
              "lng": -79.5703888
            },
            "southwest": {
              "lat": 43.83244029999999,
              "lng": -79.5704073
            }
          },
          "location": {
            "lat": 43.8324404,
            "lng": -79.5704073
          },
          "location_type": "RANGE_INTERPOLATED",
          "viewport": {
            "northeast": {
              "lat": 43.83378933029149,
              "lng": -79.5690490697085
            },
            "southwest": {
              "lat": 43.8310913697085,
              "lng": -79.57174703029152
            }
          }
        },
        "types": [
          "street_address"
        ]
      },
      {
        "address_components": [
          {
            "long_name": "56",
            "short_name": "56",
            "types": [
              "street_number"
            ]
          },
          {
            "long_name": "Rosario Drive",
            "short_name": "Rosario Dr",
            "types": [
              "route"
            ]
          },
          {
            "long_name": "Summerville",
            "short_name": "Summerville",
            "types": [
              "locality",
              "political"
            ]
          },
          {
            "long_name": "Dorchester",
            "short_name": "Dorchester",
            "types": [
              "administrative_area_level_2",
              "political"
            ]
          },
          {
            "long_name": "South Carolina",
            "short_name": "SC",
            "types": [
              "administrative_area_level_1",
              "political"
            ]
          },
          {
            "long_name": "United States",
            "short_name": "US",
            "types": [
              "country",
              "political"
            ]
          },
          {
            "long_name": "29483",
            "short_name": "29483",
            "types": [
              "postal_code"
            ]
          }
        ],
        "formatted_address": "56 Rosario Drive, Summerville, SC 29483, USA",
        "geometry": {
          "bounds": {
            "northeast": {
              "lat": 33.0303119,
              "lng": -80.2500213
            },
            "southwest": {
              "lat": 33.0302964,
              "lng": -80.2500223
            }
          },
          "location": {
            "lat": 33.0302964,
            "lng": -80.2500213
          },
          "location_type": "RANGE_INTERPOLATED",
          "viewport": {
            "northeast": {
              "lat": 33.0316531302915,
              "lng": -80.24867281970849
            },
            "southwest": {
              "lat": 33.0289551697085,
              "lng": -80.25137078029151
            }
          }
        },
        "partial_match": true,
        "types": [
          "street_address"
        ]
      },
      {
        "address_components": [
          {
            "long_name": "56",
            "short_name": "56",
            "types": [
              "street_number"
            ]
          },
          {
            "long_name": "Rosario Drive",
            "short_name": "Rosario Dr",
            "types": [
              "route"
            ]
          },
          {
            "long_name": "Silver Lake",
            "short_name": "Silver Lake",
            "types": [
              "neighborhood",
              "political"
            ]
          },
          {
            "long_name": "Providence",
            "short_name": "Providence",
            "types": [
              "locality",
              "political"
            ]
          },
          {
            "long_name": "Providence",
            "short_name": "Providence",
            "types": [
              "administrative_area_level_2",
              "political"
            ]
          },
          {
            "long_name": "Rhode Island",
            "short_name": "RI",
            "types": [
              "administrative_area_level_1",
              "political"
            ]
          },
          {
            "long_name": "United States",
            "short_name": "US",
            "types": [
              "country",
              "political"
            ]
          },
          {
            "long_name": "02909",
            "short_name": "02909",
            "types": [
              "postal_code"
            ]
          }
        ],
        "formatted_address": "56 Rosario Drive, Providence, RI 02909, USA",
        "geometry": {
          "bounds": {
            "northeast": {
              "lat": 41.8053438,
              "lng": -71.4620833
            },
            "southwest": {
              "lat": 41.8053382,
              "lng": -71.4621001
            }
          },
          "location": {
            "lat": 41.8053382,
            "lng": -71.4620833
          },
          "location_type": "RANGE_INTERPOLATED",
          "viewport": {
            "northeast": {
              "lat": 41.8066899802915,
              "lng": -71.46074271970849
            },
            "southwest": {
              "lat": 41.8039920197085,
              "lng": -71.46344068029151
            }
          }
        },
        "partial_match": true,
        "types": [
          "street_address"
        ]
      }
    ],
    "status": "OK"
  }
  </code></pre>
  
  <p>My Code:</p>
  
  <pre><code>if (response != null)
              {
                  JSONObject json;
                  try {
                      json = new JSONObject(response);
                      JSONObject results = json.getJSONObject("results");
                      JSONArray geometry = results.getJSONArray("geometry");
                      JSONArray location = geometry.getJSONArray("location");
  
  
  
  
                  } catch (JSONException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>On this line:                   JSONArray location = geometry.getJSONArray("location");
  
  The method getJsonArray(int) in the type JSONArray is not applicable for the arguments String.
  </code></pre>