1 // json转换为map 2 public static Map parserToMap(String s) { 3 Map map = new HashMap(); 4 JSONObject json = JSONObject.fromObject(s); 5 Iterator keys = json.keys(); 6 while (keys.hasNext()) { 7 String key = (String) keys.next(); 8 String value = json.get(key).toString(); 9 if (value.startsWith("{") && value.endsWith("}")) { 10 map.put(key, parserToMap(value)); 11 } else { 12 map.put(key, value); 13 } 14 } 15 return map; 16 }