voglio leggere queste righe JSON ma perché iniziare con JSONArray im un po 'confusocome analizzare JSONArray in Android
"abridged_cast": [
{
"name": "Jeff Bridges",
"id": "162655890",
"characters": [
"Jack Prescott"
]
},
{
"name": "Charles Grodin",
"id": "162662571",
"characters": [
"Fred Wilson"
]
},
{
"name": "Jessica Lange",
"id": "162653068",
"characters": [
"Dwan"
]
},
{
"name": "John Randolph",
"id": "162691889",
"characters": [
"Capt. Ross"
]
},
{
"name": "Rene Auberjonois",
"id": "162718328",
"characters": [
"Bagley"
]
}
],
Ho solo bisogno di utilizzare il "nome" e salvare tutti come una stringa. (il valore della stringa sarà: Jeff Bridges, Charles Grodin, Jessica Lange, John Randolph, Rene Auberjonois).
questo è il mio codice:
try {
//JSON is the JSON code above
JSONObject jsonResponse = new JSONObject(JSON);
JSONArray movies = jsonResponse.getJSONArray("characters");
String hey = movies.toString();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
puoi pubblicare la stringa json completa? –
Si sta recuperando l'array con il nome sbagliato. –
Dovrebbe essere 'getJSONArray (" abridged_cast ")' e quindi for-loop – vorrtex