I want to parse JSON with any key on Android. JSON data consists of any key, array or values. Here are JSON data and my working code. I want to put JSON data into a class by
Yes this is possible.
Put the JSON you receive in a JSONObject
. You can loop trough the keys
and get the values
out of it.
Example:
//Create json object from string
JSONObject newJson = new JSONObject(json);
// Get keys from json
Iterator<String> panelKeys = newJson.keys();
while(panelKeys.hasNext()) {
JSONObject panel = newJson.getJSONObject(panelKeys.next()); // get key from list
String id = panel.getString("id");
String number = panel.getString("number");
}
I hope this is what you were looking for