FastJson JSONArray与JSONObject

1.请求他人接口出参是JSONArray,实际接收时候不能用JSONArray,可以用List<JSONObject> list=(List<JSONObject> result.getData()),遍历List<JSONObject>时候,也不能直接强转成JSONObject,否则报LinkedHashMap不能转成fast.json.JSONObject,JSONObject jsonobject=new JSONObject(list.get(i));

或者是JSONArray jsonarray = new JSONArray(List<Object> result.getData());

ArrayList arrayList = (ArrayList)body.getData();

JSONArray jsonarray = (JSONArray)JSONArray.toJSON(arrayList);

猜你喜欢

转载自blog.csdn.net/qq_34412985/article/details/81071247