1. 程式人生 > >object' is an array. Use JSONArray instead

object' is an array. Use JSONArray instead

list集合轉換JSON出錯誤

意思是:物件”是一個數組。使用jsonarray代替。

解決方法:

將JSONObject替換為JSONArray

程式碼:

JsonConfig jsonConfig = new JsonConfig();

jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);

JSONArray json = JSONArray.fromObject(你的list, jsonConfig);

result = json.toString();