总结
String => 对象

List<Alarm> alarm_list = mapper.readValue(alarms,new TypeReference<List<Alarm>>() { });

对象 => String

String jsonStr = mapper.writeValueAsString(paramMap);

底下的不用看

Map 转 User
Map<String,String> map = new LinkedHashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
User user = objectMapper.convertValue(map, User.class);
List<map> 转 List<User>
List<HashMap> result;
ObjectMapper objectMapper = new ObjectMapper()
List<Clazz> list = objectMapper.convertValue(lists, new TypeReference<List<Clazz>>(){});
Json_str 转 List<User>
alarms 为string类型的json数据
ObjectMapper mapper = new ObjectMapper();
List<Alarm> alarm_list = mapper.readValue(alarms,new TypeReference<List<Alarm>>() { });
Map 转 Json_str
ObjectMapper objectMapper = new ObjectMapper();
String jsonStr = mapper.writeValueAsString(paramMap);
===========================================

User 转 Map

AlarmRuleMerge m;
Map map = JSONObject.parseObject(JSONObject.toJSONString(m), Map.class);
String 转 Map
Map resultMap = JSON.parseObject(str);
List<User> 转 List<Map>
Object data = resultMap.get(“data”);
List<Map> dataList = JSONObject.parseObject(JSONObject.toJSONString(data), List.class);

————————————————
版权声明:本文为CSDN博主「天明丶super」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tianmingkiss/article/details/108261425