net.sf.json.JSONException: 'object' is an array. Use JSONArray instead

list集合转换JSON出错误

意思是:对象是一个数组。

使用jsonarray取代。

解决方法:

将JSONObject替换为JSONArray

代码:

JsonConfig jsonConfig = new JsonConfig();

jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);

JSONArray json = JSONArray.fromObject(newList, jsonConfig);

result = json.toString();


posted on 2016-04-09 19:35  gcczhongduan  阅读(231)  评论(0编辑  收藏  举报