Ich habe dieses jsonJSONObject zu Arraylist? Warum diese JSONException?
{
"summary":
{
"total_count":2
},
"data":
[
{
"id":"129393910815742",
"name":"Mike Pollito"
},
{
"id":"117161088707629",
"name":"James Carballo"
}
],
"paging":
{
"cursors":
{
"after":"mUhn",
"before":"QVFn"
}
}
}
und ich brauche die IDs in einem ArrayList
oder einer einfachen Array zu speichern.
Hinweis: Die Anzahl der IDs kann variieren.
Das Problem ist, als ich leicht "TOTAL_COUNT" mit
int amigos = listatodoslosamigos.getJSONObject("summary").getInt("total_count");
bekommen kann, aber wenn ich versuche, jede "id" zu bekommen, wenn ich rufe
JSONObject data = listatodoslosamigos.getJSONObject("data");
ich immer ein JSONException bekommen
Dies ist mein Fehlercode
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();
"Daten" ist ein Array. Versuchen Sie es mit 'JSONArray data = listatodoslosamigos.getJSONObject (" data ");' –