这个错误是由于操作的json字符串,使用string类型有误。
我要把object对象recomdList解析出来,应该是一个list<T>,代码里需要把recomdList转成string,我直接转报错,应该是转成json才对。JSONObject.toJSONString(recomdList)
一个object对象recomdList转成List<T>代码:
if (recomdList instanceof String){
}else if (recomdList instanceof ArrayList<?>) {
Gson gson = new Gson();
JsonArray arry = new JsonParser().parse(JSONObject.toJSONString(recomdList)).getAsJsonArray();
for (JsonElement jsonElement : arry) {
recomd_list.add(gson.fromJson(jsonElement,ProductsRecommendListBean.class));
}
}
来源:CSDN
作者:那个游侠
链接:https://blog.csdn.net/shsh_0415/article/details/103964190