首页 > 技术文章 > Jackson 字符串转List<Map>

lly001 2018-09-08 16:51 原文

String a = "[{\"id\":27,\"text\":\"网络\"},{\"id\":32,\"text\":\"机身内存\"}]";
ObjectMapper objectMapper = new ObjectMapper();
CollectionLikeType type = objectMapper.getTypeFactory().constructCollectionLikeType(List.class, Map.class);
List<Map> listMap = objectMapper.readValue(a, type);

  

ObjectMapper objectMapper = new ObjectMapper();
CollectionLikeType type = objectMapper.getTypeFactory().constructCollectionLikeType(List.class, Map.class);
List<Map> listMap = objectMapper.readValue(typeTemplate.getSpecIds(), type);

推荐阅读