1.引入com.alibaba.fastjson.JSONArray包
String str = "";
List<SowDetailDto> sowDetailDtos = JSONArray.parseArray(str, SowDetailDto.class);
for (SowDetailDto s : sowDetailDtos) {
System.out.println(s.getCurrentBarnName());
}
2.引入net.sf.json.JSONArray包
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);