How do I retrieve info from a nested JSON response?
<p>I'm retrieving a JSON response and have no problems except for one part. Some items are nested JSONObjects:</p>

<pre><code>{
"response": {
    "venues": [
        {
            "id": "42829c80f964a5205f221fe3",
            "name": "AmericanExpressTower",
            "contact": {
                "phone": "2126405130",
                "formattedPhone": "(212)640-5130",
                "twitter": "americanexpress"
            },
            "location": {
                "address": "200VeseySt",
                "crossStreet": "WestSt",
                "lat": 40.713618978735,
                "lng": -74.01408649911748,
                "distance": 1926,
                "postalCode": "10285",
                "city": "NewYork",
                "state": "NY",
                "country": "UnitedStates"
            }
        }
    ]
}
</code></pre>

<p>}</p>

<p>How can I access one item in the contact object like "formattedPhone"?</p>

<p>I can access the "name" of each item fine:</p>

<pre><code>JSONObject json = new JSONObject(result);  

JSONArray venues = json.getJSONObject("response")
      .getJSONArray("venues"); 
input.close();  
int vLength = venues.length();
StringBuilder builder = new StringBuilder();
for (int i = 0; i &lt; vLength; i++) {
  builder.append("Location: ");
  builder.append(venues.getJSONObject(i)
      .getString("name").toString());    
  builder.append("\n");          
}
</code></pre>
