fastjson和 gson 的反序列化的一个差异
public class Response01 { private ThirdData thirdData; public ThirdData getThirdData(){ return thirdData; } // ThirdData extend BaseThirdData public void setThirdData(BaseThirdData thirdData){ this.thirdData=thirdData; } }
gson:
Gson GSON= new Gson();
GSON.fromJson(jsonString,clazz);
尽管setThirdData(BaseThirdData )但是可以反序列化到ThirdData
fastjson:
JSONObject.parseObject(jsonString,clazz);
只能反序列化到BaseThirdData,即尽管jsonString 里面有ThirdData的字段,但是只能反序列化BaseThirdData