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
 
 
相關文章
相關標籤/搜索