java - Can't get Json android -


i want output json, have error

06-02 23:10:26.110: w/system.err(23235): org.json.jsonexception: value data of type java.lang.string cannot converted jsonobject 06-02 23:10:26.116: w/system.err(23235):    @ org.json.json.typemismatch(json.java:111) 06-02 23:10:26.117: w/system.err(23235):    @ org.json.jsonobject.<init>(jsonobject.java:158) 06-02 23:10:26.117: w/system.err(23235):    @ org.json.jsonobject.<init>(jsonobject.java:171) 

i create code whith example, json:

{     "status": "success",     "data": {         "users_information": [             {                 "id": "1",                 "active": "1",             }, {                 "id": "2",                 "active": "1",             }]}} 

it's code:

 jsonobject data = new jsonobject("data");                   jsonarray userinform = data.getjsonarray("users_information");                   for(int = 0; < userinform.length(); i++) { jsonobject c = userinform.getjsonobject(i);  log.e("id ", c.getstring("id")); } 

string data = "{     "status": "success",     "data": {         "users_information": [             {                 "id": "1",                 "active": "1",             }, {                 "id": "2",                 "active": "1",             }]}}" 

parse json

jsonobject data = new jsonobject(data);                   jsonarray userinform = data.getjsonarray("users_information");                   for(int = 0; < userinform.length(); i++) { jsonobject c = userinform.getjsonobject(i);  log.e("id ", c.getstring("id")); } 

the string data json can replaced json received backend


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -