json - Java - get the last element in a JsonObject -


i using java pull json object off internet.

how last element of json object?

the key timecode wondering if possible skip using jsonobject.get(timecode); method , last element of object?

this json object returned:

{"daily":{"1437436800000":271,"1437523200000":271,"1437609600000":271,"1437696000000":271,"1437782400000":271,"1437868800000":271}}

any appreciated

thanks

ok have found solution.

the .keys() method not available me when using gson library. method available in maven repository: org.json

@suppresswarnings("unchecked") public static list<object> getlistfromjsonobject(jsonobject jobject) throws jsonexception {       list<object> returnlist = new arraylist<object>();       iterator<string> keys = jobject.keys();        list<long> keyslist = new arraylist<long>();       while (keys.hasnext()) {         keyslist.add(long.parselong(keys.next()));        }       collections.sort(keyslist); //sort list        (long key : keyslist) {           returnlist.add(jobject.get(key.tostring()));       }        return returnlist;     } 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -