序列化反序列化
作者:互联网
序列化:
对象转json
1 ObjectMapper objectMapper = new ObjectMapper();
2 String jsonStr = objectMapper.writeValueAsString(dataDTO);
反序列化:
json转列表
1 ObjectMapper objectMapper = new ObjectMapper();
2 objectMapper.readValue(jsonStr, new TypeReference<List<FundStatsPeriodConfig>>() {});
json转对象
1 ObjectMapper objectMapper = new ObjectMapper();
2 DataDTO dataDTO = objectMapper.readValue(jsonStr, DataDTO.class);
标签:jsonStr,json,ObjectMapper,new,序列化,objectMapper 来源: https://www.cnblogs.com/yxl-wyb/p/16547947.html