标签:
字符串转换为json对象:
String strResult = RestUtil.getRestContent(url+"/service/peccancy/myOrderList", mappeccancy);
JSONObject obj = JSONObject.fromObject(strResult);
json对象转换成list集合:
JSONArray objData = (JSONArray)obj.get("data"); //获取data字段
peccancyList=(List<PeccancyVO>)objData.toCollection(objData, PeccancyVO.class);
json对象转换成对象:
PeccancyVO vo=(PeccancyVO)JSONObject.toBean(obj,PeccancyVO.class);
这里注意:对象一定要有无参的构造方法,否则会报错:java.lang.nosuchmethodexception <init>
标签:
原文地址:http://www.cnblogs.com/liuying1995/p/5799762.html