Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 2.0.20 反序列化报错 , 不同api表现不一样 #1000

Closed
WangChenPeng opened this issue Dec 7, 2022 · 2 comments
Closed

[BUG] 2.0.20 反序列化报错 , 不同api表现不一样 #1000

WangChenPeng opened this issue Dec 7, 2022 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@WangChenPeng
Copy link

WangChenPeng commented Dec 7, 2022

问题描述

简要描述您碰到的问题。
反序列化对象失败 试了3种api 2种报错 1种正常 见下面代码

环境信息

请填写以下信息:

  • 版本信息:2.0.20

重现步骤

`public static void main(String[] args) {
    String json = "{\"whiteListIds\":[]}";
    JSONObject.parseObject(json).toJavaObject(TestObj.class); //报错
    JSONObject.parseObject(json).to(TestObj.class);  //报错
    JSON.parseObject(json,TestObj.class); //正常
}

@Data
public class TestObj{

    private Set<Integer> whiteListIds;

}

`

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。

相关日志输出

Exception in thread "main" com.alibaba.fastjson2.JSONException: set whiteListIds error
at com.alibaba.fastjson2.reader.FieldReaderObject.accept(FieldReaderObject.java:268)
at com.alibaba.fastjson2.reader.ObjectReader.createInstance(ObjectReader.java:126)
at com.alibaba.fastjson2.JSONObject.to(JSONObject.java:1210)
at com.alibaba.fastjson2.JSONObject.toJavaObject(JSONObject.java:1220)
at com.x.x.x.x.x.Test.main(Test.java:23)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.alibaba.fastjson2.reader.FieldReaderObject.accept(FieldReaderObject.java:264)
... 4 more

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@WangChenPeng WangChenPeng added the bug Something isn't working label Dec 7, 2022
@wenshao wenshao added this to the 2.0.22 milestone Dec 10, 2022
@wenshao
Copy link
Member

wenshao commented Dec 11, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.22-SNAPSHOT/
问题已修复,请帮忙用2.0.22-SNAPSHOT版本验证,2.0.22版本预计在元旦期间发布

@wenshao
Copy link
Member

wenshao commented Dec 31, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.22
问题已修复,请用新版本

@wenshao wenshao closed this as completed Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants