List<bean> 转换成List<Map>

//将listmap转换成list实体类
        List<OaAttachment>list=new ArrayList<OaAttachment>();
        if(Func.isNotEmpty(attachments)){
            for(Map<String,Object> map:attachments){
                OaAttachment fileInfo=new OaAttachment();
                fileInfo= JSONObject.parseObject(JSONObject.toJSONString(map),OaAttachment.class);
                list.add(fileInfo);
            }
        }

//将list实体类转换成list map

List<Map<String,Object>>mapList=new ArrayList<>();
            for(OaAttachmentContract files:bean.getAttachments()){
                Map<String,Object>map=new HashMap<String,Object>();
                map=JSONObject.parseObject(JSONObject.toJSONString(files),Map.class);
                mapList.add(map);
            }

 

posted @ 2020-09-16 08:31  红尘沙漏  阅读(5527)  评论(0编辑  收藏  举报