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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -