Can't parse json object(android) -


sorry english, can't parse json object this:

{     "user": {         "id": 34,         "last_login": {             "date": "2015-07-30 11:22:34.000000",             "timezone_type": 3,             "timezone": "europe/oslo"         }     } } 

i don't know, why it's not working. need parse last_login, can't this

my code

jsonobject jsontable = json.getjsonobject("user");                  if(jsontable.length() > 0) {                     check = true;                      profiledetalisobject pfdet = new profiledetalisobject();                      pfdet.setid(jsontable.getstring(tag_id));                       jsonobject date = jsontable.getjsonobject("last_login");                     if(date.length() > 0) {                         iterator<string> iteratordate = date.keys();                          while( iteratordate.hasnext() ) {                             string currentkeysensor = iteratordate.next();                             jsonobject objdate = date.optjsonobject(currentkeysensor);                              if(objdate != null) {                                 pfdet.setdate(objdate.getstring("date"));                                 pfdet.settimezone_type(objdate.getstring("timezone_type"));                                 pfdet.settimezone(objdate.getstring("timezone"));                             }                         }                     } 

i can't parse last_login.

last_login normal json object (aka dictionary), not need iterators, reach keys directly:

jsonobject date = jsontable.getjsonobject("last_login"); pfdet.setdate(date.getstring("date")); pfdet.settimezone_type(date.getstring("timezone_type")); pfdet.settimezone(date.getstring("timezone")); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -