后台字符串转成Json

/**
* 从context的json中提取出reportData
* @param favoriteList
*/
public static void getReportDataFromContext(List<Favorite> favoriteList){
if(favoriteList == null){
return;
}

for (Favorite favorite : favoriteList) {
if (favorite == null) {
continue;
}

String context = favorite.getJson();
if (StringUtils.isBlank(context)) {
continue;
}

JSONObject jsonObject = JSONObject.fromObject(context);
ReportData reportData = (ReportData) JSONObject.toBean(
jsonObject, ReportData.class);
if (reportData == null) {
continue;
}
reportData.setContent(reportData.getContent());
favorite.setReportData(reportData);
}
}

猜你喜欢

转载自llljyblll.iteye.com/blog/2259825