get key name & key value from json get key name & key value from json json json

get key name & key value from json


Try using this

JSONObject json_array = args.optJSONObject(0);Iterator<?> keys = json_array.keys();while( keys.hasNext() ) {    String key = (String) keys.next();    System.out.println("Key: " + key);    System.out.println("Value: " + json_array.get(key));}


as your new to Java and JSON is one of the most famous data interchange language out there, I recommend you to understand the parsing and the structure of JSON thoroughly this example.

for (String key: jsonObject.keySet()){ System.out.println(key);}

This will fetch you the set of Keys in the JSON.