LinkedHashMap转ArrayList

第一种、LinkedHashMap转数组,数组再转成ArrayList

ObjectMapper objectMapper=new ObjectMapper();
ResultPortalBean rpb=(ResultPortalBean)objectMapper.readValue(data,ResultPortalBean.class);
UserInfoBO[] userArr=(UserInfoBO[])objectMapper.readValue(objectMapper.writeValueAsString(rpb.getData),UserInfoBO[].class);
List userList=Arrays.asList(userArr);

第二种、jackson自带convertValue方法转换

ObjectMapper objectMapper=new ObjectMapper();
ResultPortalBean rpb=(ResultPortalBean)objectMapper.readValue(data,ResultPortalBean.class);
List userList=( List)objectMapper.convertValue(objectMapper.writeValueAsString(rpb.getData),new TypeReference>(){});

你可能感兴趣的:(LinkedHashMap转ArrayList)