/json字符串转成map集合
private Map<String, Object> getMapFromJson(String message) {
// TODO Auto-generated method stub
Map<String, Object> mapList = JSON.parseObject(message);
return mapList;
}
//map集合转json字符串
Map<String, Object> map = getMapFromJson(message);
ObjectMapper json = new ObjectMapper();
String params = json.writeValueAsString(map);
System.out.println("++++++++++++++++++转成的json格式字符串:"+params);
本文介绍了如何将JSON字符串转换为Map集合,以及如何将Map集合转换回JSON字符串的方法。通过示例代码展示了使用Java进行数据格式转换的具体实现,适用于需要在不同数据格式间进行转换的开发场景。

1万+

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



