首页 > 技术文章 > ObjectMapper将List和String互转

pzw23 2021-03-04 17:12 原文

ObjectMapper objectMapper = new ObjectMapper();

List<Cell>cells=new ArrayList();

//List转String
String str= objectMapper.writeValueAsString(cells);

//String转List
List<Cell> cellList = objectMapper.readValue(str, new TypeReference<List<Cell>>() {});

 

推荐阅读