2016-05-27 16 views
0

Ich habe diese json Ich habe zu bekommen: „id“Der Versuch, die JSONObject in einem JSONObject

{ 
    "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":[ 

     ] 
    }, 
... 

Ich will alles erhalten, die auf 0 beginnt die 0, so habe ich dies:

JSONObject tv1 = jObj.getJSONObject("0"); 

Und es funktioniert, aber dann zu bekommen ich versuche, die "fotos" so wie ich dies tat:

JSONObject tv1Fotos = tv1.getJSONObject("fotos"); 

Und es dosent Arbeit. Es wird warf Methode JSONException

+0

Statt JSONObject tv1Fotos = tv1.getJSONObject ("fotos"); benutze JSONArray tv1Fotos = tv1.getJSONArray ("fotos"); – Crash

Antwort

6

Weil Sie anrufen getJSONObject() und fotos ein Array ist

Verwendung getJSONArray() statt