java - JSONArray within JSONArray -


i'm confused why cannot pull jsonarray jsonarray in android application. example , snippet of source code given below.

//the json     {      "currentpage":1,      "data":[         {           "id":"dimtrs",           "name":"bud light",           "breweries":[               {                 "id":"bznaha",                 "name":"anheuser-busch inbev",               }            ]         }     ],     "status":"success"   } 

now i'm trying retreive "breweries" array.

//code snippet  ...  jsonobject jsonobject = new jsonobject(inputline);  jsonarray jarray = jsonobject.getjsonarray("data");  jsonarray jsarray = jarray.getjsonarray("breweries");  ... 

i can pull objects out of data array fine, cannot "breweries" array "data" array using current code.

the error jsarray is:

the method .getjsonarray(int) in type jsonarray not applicable arguments string

so correct way pull "breweries" array out of "data" array?

thanks in advance!

it because "breweries" in 1st object of "data" array, not directly on array itself. trying key array.

so want call jarray.getjsonobject(0).getjsonarray("breweries"); or effect.

as sambhav sharma explains in comment, reason error methods jsonarray expect int , not string argument.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -