java - Iterating over a json array of arrays -


i have json array comes this

[{"item":"value"},{"item":"value"},{"item":"value"},{"item":"value"}] 

i attempting loop on array , grab "item" code such below, value never grabbed, can confirm array have values somehow returns null

    arraylist<arraylist<object>> mainlist = new arraylist<arraylist<object>>();      string json = getjson(url, null);      jsonobject jsonobject = null;      try {         jsonobject = new jsonobject(json);          int counter = 0;          jsonarray itemarray = new jsonarray();         itemarray.put(jsonobject);          while(counter < itemarray.length()){              //create inner array             arraylist<object> innerlist = new arraylist<object>();              //grab contents of post             jsonobject item = itemarray.getjsonobject(counter);              //place items inner array             innerlist.add(counter + 1);             innerlist.add(item.getstring("item"));               //place inner array main array             mainlist.add(innerlist);              counter++;         }            return mainlist;     } catch (jsonexception e) {         e.printstacktrace();          return null;     } 

there little info on problem (stacktrace??), not seem correct

 item.getstring("name"); 

try

 item.getstring("item"); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -