You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
null
Exception in thread "main" com.alibaba.fastjson2.JSONException: create instance error, class Test$Foo
at com.alibaba.fastjson2.reader.ObjectReaderAdapter.createInstance(ObjectReaderAdapter.java:411)
at com.alibaba.fastjson2.reader.ObjectReaderBean.readObject(ObjectReaderBean.java:386)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:864)
at Test.main(Test.java:19)
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.alibaba.fastjson2.reader.ObjectReaderAdapter.createInstance(ObjectReaderAdapter.java:405)
... 3 more
期待结果
fastjson2和fastjson对于抽象类反序列化默认行为一致,或至少提供配置项控制。
The text was updated successfully, but these errors were encountered:
Have you tried instead of directly deserializing the abstract class, deserialize a concrete subclass that extends the abstract class?
This way, you can avoid the exception thrown by fastjson2.
问题描述
fastjson2和fastjson抽象类反序列化默认行为不一致,fastjson2在反序列化抽象类时会抛出异常,fastjson会跳过该类。并没有找到配置项控制该行为。
重现步骤
结果
期待结果
fastjson2和fastjson对于抽象类反序列化默认行为一致,或至少提供配置项控制。
The text was updated successfully, but these errors were encountered: