I have a JSONObject with some attributes that I want to convert into a Map
Is there something that I can use from the
This is what worked for me:
public static Map toMap(JSONObject jsonobj) throws JSONException {
Map map = new HashMap();
Iterator keys = jsonobj.keys();
while(keys.hasNext()) {
String key = keys.next();
Object value = jsonobj.get(key);
if (value instanceof JSONArray) {
value = toList((JSONArray) value);
} else if (value instanceof JSONObject) {
value = toMap((JSONObject) value);
}
map.put(key, value);
} return map;
}
public static List
Most of this is from this question: How to convert JSONObject to new Map for all its keys using iterator java