{ "key1": "value1", "key2": "value2", "key3": "value3" }
How I can get each item's key and value without knowing the key nor value beforehand?
Use the keys() iterator to iterate over all the properties, and call get() for each.
keys()
get()
Iterator<String> iter = json.keys(); while (iter.hasNext()) { String key = iter.next(); try { Object value = json.get(key); } catch (JSONException e) { // Something went wrong! } }
1.4m articles
1.4m replys
5 comments
57.0k users