java - Convert Json String to List in andriod -


    strresponse = {"getcitiesresult":["1-vizag","2-hyderbad","3-pune","4-chennai","9-123","11-rohatash","12-gopi","13-rohatash","14-rohatash","10-123"]}   jsonobject json = new jsonobject(strresponse);              // ll json object  string json_ll = json.getjsonobject("getcitiesresult").tostring();  

now want convert json string list in andriod

please make sure response string correct format, if is, try this:

try {     arraylist<string> list = new arraylist<string>();     jsonobject json = new jsonobject(strresponse);     jsonarray array = json.getjsonarray("getcitiesresult");     (int = 0; < array.length(); i++) {         list.add(array.getstring(i));     } } catch (exception e) {     e.printstacktrace(); } 

Comments