fastjson的坑 com.alibaba.fastjson.JSONObject cannot be cast to xxx

解析json对象时,使用了new TypeReference()对象
fastjson会对解析的对象类型进行缓存
 
new TypeReference<ResultData>(){}  使用这种方式后,会致使下面的json对象解析失败,返回jsonObject类型
new TypeReference<ResultData<ItemTO>>(){}
解决方法:对于没有返回值的对象,使用ResultData<Void>,不直接使用ResultData
 
 
相关文章
相关标签/搜索