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);