String jsonString="[{'id':'1'},{'id':'2'}]";
ObjectMapper mapper = new ObjectMapper();
JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, Bean.class);
//如果是Map类型 mapper.getTypeFactory().constructParametricType(HashMap.class,String.class, Bean.class);
List<Bean> lst = (List<Bean>)mapper.readValue(jsonString, javaType);
Jackson 处理复杂类型(List,map)
最新推荐文章于 2021-03-04 06:30:07 发布