📅  最后修改于: 2022-03-11 15:01:23.388000             🧑  作者: Mango
public static Map jsonToMap(JSONObject json) throws JSONException {
Map retMap = new HashMap();
if(json != JSONObject.NULL) {
retMap = toMap(json);
}
return retMap;
}
public static Map toMap(JSONObject object) throws JSONException {
Map map = new HashMap();
Iterator keysItr = object.keys();
while(keysItr.hasNext()) {
String key = keysItr.next();
Object value = object.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