JSONObject to arraylist? Why this JSONException?
<p>I have this json</p>

<pre><code>{
    "summary":
    {
        "total_count":2
    },
    "data":
    [
        {
            "id":"129393910815742",
            "name":"Mike Pollito"
        },
        {
            "id":"117161088707629",
            "name":"James Carballo"
        }
    ],
    "paging":
    {
        "cursors":
        {
            "after":"mUhn",
            "before":"QVFn"
        }
    }
}
</code></pre>

<p>and I need to save the ids in an <code>ArrayList</code> or any simple array. </p>

<p>Note:The number of ids may vary.</p>

<p>The problem is than i can easily get "total_count" with </p>

<pre><code>int amigos = listatodoslosamigos.getJSONObject("summary").getInt("total_count");
</code></pre>

<p>but when i try to get any "id" when i call</p>

<pre><code>JSONObject data = listatodoslosamigos.getJSONObject("data");
</code></pre>

<p>i always get a JSONException   </p>

<p>This is my buggy code</p>

<pre><code>public void onCompleted(GraphResponse response) {
        /* handle the result */
                     JSONObject listatodoslosamigos = response.getJSONObject();
                    try {
                        int amigos = listatodoslosamigos.getJSONObject("summary").getInt("total_count");
                        JSONObject data = listatodoslosamigos.getJSONObject("data");

                    } catch (JSONException e) {}
                }
            }
    ).executeAsync();
</code></pre>