首页 > 编程知识 正文

json字符串转listmap集合,json数组字符串转list集合

时间:2023-05-06 13:00:36 阅读:240624 作者:3430

1.引入com.alibaba.fastjson.JSONArray开心的老鼠/p> String str = "";List<SowDetailDto> sowDetailDtos = JSONArray.parseArray(str, SowDetailDto.class);for (SowDetailDto s : sowDetailDtos) { System.out.println(s.getCurrentBarnName());}

2.引入net.sf.json.JSONArray开心的老鼠/p> String str = "";JSONArray json = JSONArray.fromObject(str);// 转对象集合List<SowDetailDto> list = (List<SowDetailDto>) JSONArray.toCollection(json, SowDetailDto.class);for (SowDetailDto s : list) { System.out.println(s.getCurrentBarnName());}// 转对象SowDetailDto sd=(SowDetailDto)JSONObject.toBean(json, SowDetailDto.class);

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。