1、将JSON字符串转换成List结果集的方式:
//查询结果集 PageDatums picPageDatums = pictureLibraryService.selectPagePictureForService(pageDatums, pictureLibrary); String picLibraryJson = picPageDatums.getJsonResult();
JSONArray jsonArray = JSONArray.fromObject(picLibraryJson);
List<CmsPictureLibrary> list = (List<CmsPictureLibrary>) JSONArray.toCollection(jsonArray,CmsPictureLibrary.class);
//如果结果集中不为空
if (null != list) {
//迭代的方式获得所有的图片的数据结果集,相当于又查询了24次数据
for(CmsPictureLibrary cmsPictureLibrary : list) {
logger.info(cmsPictureLibrary);
}
}
2、将List结果集变成json串的方式:
JSONObject.valueToString(这里是List对象或其它对象)