java - Android Gson Json parse when key number is undefined -


i have following json response

{   "time": {         "1427817600000": 90,         "1427904000000": 134,         "1427990400000": 155,         "1428076800000": 167   } } 

and number of items in "time" undefined.

for example,

at time "1427817600000", count 90

at time "1427904000000", count 134 ... ...

how can parse in android (java)

thanks.

you can iterate each , every key of "time" json using org.json library

e.g.

string data = "{\"time\": {\"1427817600000\": 90,\"1427904000000\": 134,\"1427990400000\": 155,\"1428076800000\": 167}}";  jsonobject json=new jsonobject(data);    jsonobject timejson=json.getjsonobject("time");  iterator<string> keys=timejson.keys(); while (keys.hasnext()){  system.out.println(timejson.get(keys.next())); } 

Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -