Parsing JSON in Android Application -


old json:

{ "listing" : [      {     "id" : "l101",     "name" : "paul"      }    ] } 

and code parse json,

private static final string tag_listing = "listing";      jsonarray contacts = null;  arraylist<hashmap<string, string>> contactlist = new arraylist<hashmap<string, string>>();      jsonparser jparser = new jsonparser();      jsonobject json = jparser.getjsonfromurl(url);      try {         contacts = json.getjsonarray(tag_listing);          for(int = 0; < contacts.length(); i++){             jsonobject c = contacts.getjsonobject(i);            }       } 

but new json looks below:

 [      {     "id" : "l101",     "name" : "paul"      }  ] 

so question, need make changes in code, parse new json ?

after correcting json parse this:

private static final string tag_listing = "listing";  jsonarray contacts = null;  arraylist<hashmap<string, string>> contactlist = new arraylist<hashmap<string, string>>();  jsonparser jparser = new jsonparser();  jsonarray json = jparser.getjsonfromurl(url);  try {      for(int = 0; < json.length(); i++){         jsonobject c = json.getjsonobject(i);        }   } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -