http://www.cnblogs.com/lanxuezaipiao/archive/2013/05/24/3096437.html
/**
* 将Json对象转换成Map
*
* @param jsonObject
* json对象
* @return Map对象
* @throws JSONException
*/
public static Map toMap(String jsonString) throws JSONException {
JSONObject jsonObject = new JSONObject(jsonString);
Map result = new HashMap();
Iterator iterator = jsonObject.keys();
String key = null;
String value = null;
while (iterator.hasNext()) {
key = (String) iterator.next();
value = jsonObject.getString(key);
result.put(key, value);
}
return result;
}
本文介绍了一种将JSON对象转换为Map的方法。通过使用JSONObject类处理JSON字符串,并迭代获取所有键值对,最终将这些键值对存储到HashMap中实现转换。

被折叠的 条评论
为什么被折叠?



