Can I get value from JSONObject without mention its name? Can I get value from JSONObject without mention its name? json json

Can I get value from JSONObject without mention its name?


You can call names() on a JSONObject to get a JSONArray of the names of its elements - this would let you do logic on them or retrieve their corresponding values dynamically.


You can get all the attributes of a JSONObject like this

for(Iteraor key=jsonObject.keys();itr.hasNext();) {   jsonObject.get(key.next());}


JSONObject obj = new JSONObject(json);for(Iterator<String> keys=obj.keys();keys.hasNext();) {    obj.get(keys.next());}