序列化反序列化
序列化:
对象转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);