public class Response01 { private ThirdData thirdData; public ThirdData getThirdData(){ return thirdData; } // ThirdData extend BaseThirdData public void setThirdData(BaseThirdData thirdData){ this.thirdData=thirdData; } }
fastjson:
Gson GSON= new Gson();
GSON.fromJson(jsonString,clazz);
尽管setThirdData(BaseThirdData )但是可以反序列化到ThirdData
gson:
JSONObject.parseObject(jsonString,clazz);
只能反序列化到BaseThirdData,即尽管jsonString 里面有ThirdData的字段,但是只能反序列化BaseThirdData
标签:fastjson,BaseThirdData,gson,thirdData,序列化,ThirdData From: https://www.cnblogs.com/zt1991jskj/p/18135308