private static HashMap<String, String> toHashMap(Object object){
HashMap<String, String> data = new HashMap<String, String>();
// 将json字符串转换成jsonObject
// 使用JSONObject 的jar
// 1.commons-beanutils-1.7.0
// 2.commons-collections-3.1
// 3.commons-lang-2.5
// 4.commons-logging
// 5.ezmorph-1.0.3
// 6.json-lib-2.1-jdk15
JSONObject jsonObject = JSONObject.fromObject(object);
Iterator it = jsonObject.keySet().iterator();
// 遍历jsonObject数据,添加到Map对象
while (it.hasNext())
{
String key = String.valueOf(it.next());
String value = (String) jsonObject.get(key);
data.put(key, value);
}
return data;
}
转载于:https://my.oschina.net/u/2357905/blog/465546