map转json

if (javaObject instanceof Map) {
Map<Object, Object> map = (Map<Object, Object>) javaObject;

JSONObject json = new JSONObject(map.size());

for (Map.Entry<Object, Object> entry : map.entrySet()) {
Object key = entry.getKey();
String jsonKey = TypeUtils.castToString(key);
Object jsonValue = toJSON(entry.getValue());
json.put(jsonKey, jsonValue);
}

return json;
}

上一篇:【vue.js权威指南】读书笔记(第二章)


下一篇:Linux MySQL差异备份技巧