List转换成JSON数据出错 我不是女神ヾ 2021-09-28 21:08 334阅读 0赞 nested exception is net.sf.json.JSONException: 'object' is an array. Use JSONArray instead //最开始代码 JSONObject jsonObject = JSONObject.fromObject(list); result jsonObject; //将Object换成Array还是不行 JSONArray jsonArray1 = JSONArray.fromObject(list) result jsonArray1; //正确应该是 JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); JSONArray jsonArray = JSONArray.fromObject(list,jsonConfig); String result = jsonArray.toString(); return result;
还没有评论,来说两句吧...