How to parse a JSON without key in android? -
How to parse a JSON without key in android? -
hi having simple type of json response ,i have worked on json keys in response have values,please see response below
json
{ status: "success", country: [ { 1: "afghanistan" }, { 2: "albania" }, { 3: "algeria" }, { 4: "american samoa" }, { 5: "andorra" }, { 6: "angola" }, { 7: "anguilla" }, { 8: "antarctica" }, { 9: "antigua , barbuda" }, { 10: "argentina" }, {..... . . . . .so on..
so want parse json , want set both values in arraylist of hashmap,i have worked below,but find no path proceed,hope buddy help me.
code
jsonobj = new jsonobject(jsonstr); if (jsonobj.has("country")) { countryarray = jsonobj.getjsonarray("country"); if (countryarray != null && countryarray.length() != 0) { // looping through contacts system.out .println("::::::::::::::::my talent size:::::::::::" + countryarray.length());
the "status","country" , "1","2", etc in json array "country" keys , hence, must in double quotes. in short, json invalid. example:
{ "status": "success", "country": [ { "1": "afghanistan" } ]}
android json parsing arraylist
Comments
Post a Comment