Reputation: 163
I got this json I created:
{
"error":false,
"0":{
"tvInfo":{
"id":"0",
"nome":"A Guerra dos Tronos",
"id_tipo":"1",
"pontuacao":"8.1",
"nVotos":"780",
"data_criado":"2011-04-17",
"data_acabado":"0000-00-00",
"id_estado":"4",
"id_canaldono":"3",
"idade_aconselhavel":"16",
"tags":"war;based on novel;kingdom;dragon;king;intrigue;fantasy;world;\r\n\r\n",
"nTemporadas":"6",
"data_inserido":"2016-05-26 22:40:09",
"data_ultima_atualizacao":"2016-05-26 22:40:09"
},
"categorias":[
"Sci-Fi",
"Action & Adventure",
"Drama"
],
"descricoes":[
{
"texto":"bababababa",
"id_idioma":"1"
},
{
"texto":"bababababa",
"id_idioma":"2"
}
],
"criadores":[
[
"David Benioff",
"46",
"1970",
"USA",
"New York",
"babababa",
"",
""
],
[
"D. B. Weiss",
"0",
"1971-04-23",
"",
"",
"",
"",
""
]
],
"fotos":[
{
"tipofoto":"0",
"url":"\/uploads\/series\/gameofthrones1.png"
},
{
"tipofoto":"0",
"url":"\/uploads\/series\/gameofthrones1Background.png"
}
],
"trailers":[
]
},
...
I want to get everything that starts on 0 the"id?" 0 so I did this:
JSONObject tv1 = jObj.getJSONObject("0");
And it works, but then I'm trying to get the "fotos" so I did like this:
JSONObject tv1Fotos = tv1.getJSONObject("fotos");
And it dosent work. It gets Method threw JSONException
Upvotes: 0
Views: 83
Reputation: 2249
Because you are calling getJSONObject()
and fotos
is an array
use getJSONArray()
instead
Upvotes: 6