我想将我的Pojo
转换为List<Map<String, Object>>
public class PoJo{
private String name;
private String id;
private String date;
}
给出数据 输出应为:地图列表
[{{name:pankaj,id:102,date:2019},{name:nikhil,id:01,date:2017}]'
我尝试了
'ObjectMapper mapper = new ObjectMapper();
mapper.convertValue(ListOfPojo, ArrayList.class);'
但这会创建
[pojo1,pojo2]
如上所述
我得到了答案:
'ObjectMapper mapper = new ObjectMapper();
for(DeviceHistory eachData : pojoList){
Map<String, Object> eachRecord = mapper.convertValue(eachData, Map.class);
response.add(eachRecord);
}'