java - Error while getting JSONArray from JSONObject -


i'm trying jsonarray jsonobject, "can't create jsonarray" in logcat.

the error appears here:

jsonarray array = response_object.getjsonarray("post"); 

here code:

try {     int id;     string author;     string authoruniqueid;     string authorphotourl;     string message;     string createtime;      jsonobject response_object = new jsonobject(response);     jsonarray array = response_object.getjsonarray("post");      (int = 0; < array.length(); i++) {         jsonobject jsonobject = array.getjsonobject(i);          id = jsonobject.getint("id");         author = jsonobject.getstring("author");         authoruniqueid = jsonobject.getstring("author_unique_id");         authorphotourl = jsonobject.getstring("author_photo_url");         message = jsonobject.getstring("message");         createtime = jsonobject.getstring("created_at");          log.e("newsactivity", "added:" + author);           data.add(new newsdatamodel(id, author, authoruniqueid, authorphotourl, message, createtime));     } } catch (exception e) {     log.e(tag, "can't create jsonarray"); } 

and json:

{"error":false} {"post":[     {         "id":"6",         "author":"name..."         "author_unique_id":"id...",         "message":"message...",         "created_at":"time...",         "author_photo_url":"url..."     },      {         "id":"5",         "author":"name..."         "author_unique_id":"id...",         "message":"message...",         "created_at":"time...",         "author_photo_url":"url..."     },      {         "id":"4",         "author":"text..."         "author_unique_id":"id...",         "message":"message...",         "created_at":"time...",         "author_photo_url":"url..."     } ]} 


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -