//声明返回JSON对象
JSONObject json = new JSONObject();
json.accumulate("totalProperty", total);
//声明JSON数组
JSONArray jsonArray = new JSONArray();
for(Object o:li){
//转换为JSON对象
JSONObject j = JSONObject.fromBean(o);
//添加的JSON数组
jsonArray.put(j);
}
//屏蔽IE空列表BUG
if("[]".equals(jsonArray.toString())){
<span style="color: #333333;">JSONArray jArray = new JSONArray();
JSONObject j = new JSONObject();
j.accumulate("noResult", 1);
jArray.put(j);
json.accumulate("root", jArray);</span>
}else{
json.accumulate("root", jsonArray);
}
return json.toString();
ExtJs 操作JSON对象
最新推荐文章于 2024-07-08 19:08:19 发布