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

> 复测过,升级到fastjson 2.0.10兼容版本和fastjson2 2.0.10 不会抛出异常。 json字符串里面params属性的值是null 转换后的bo的params还是null,没有赋值 #605

Closed
leblancvn opened this issue Aug 2, 2022 · 4 comments
Milestone

Comments

@leblancvn
Copy link

leblancvn commented Aug 2, 2022

复测过,升级到fastjson 2.0.10兼容版本和fastjson2 2.0.10 不会抛出异常。 json字符串里面params属性的值是null 转换后的bo的params还是null,没有赋值

使用了2.0.10版本是当使用了lombok的@accessors(chain = true)注解的时候依然会报错.

@Setter
@Getter
@Accessors(chain = true)
public class WinningInformationBo{
    private boolean isSuccess;
    private String wxId;
    private Map<String, String> parems;
}

编译后的类为:

public class WinningInformationBo{
    private boolean isSuccess;
    private String wxId;
    private Map<String, String> parems;

    public TestVO() {
    }

    public TestVO setSuccess(final boolean isSuccess) {
        this.isSuccess = isSuccess;
        return this;
    }

    public TestVO setWxId(final String wxId) {
        this.wxId = wxId;
        return this;
    }

    public TestVO setParems(final Map<String, String> parems) {
        this.parems = parems;
        return this;
    }

    public boolean isSuccess() {
        return this.isSuccess;
    }

    public String getWxId() {
        return this.wxId;
    }

    public Map<String, String> getParems() {
        return this.parems;
    }
}

Originally posted by @leblancvn in #596 (comment)

wenshao added a commit that referenced this issue Aug 3, 2022
wenshao added a commit that referenced this issue Aug 3, 2022
@leblancvn
Copy link
Author

@Setter
@getter
@accessors(chain = true)
public class WinningInformationBo {
private boolean isSuccess;
private String wxId;
private Map<String, String> parems;
}

String str3 = "{"wx_id":"xxx","success":true,"parems":null}";
WinningInformationBo bo = JSON.parseObject(str3, WinningInformationBo.class);
此时会报错抛出异常。
使用fastjson 2.0.10兼容版本和fastjson2 2.0.10都会报错。
期望值是null时不用赋值

@wenshao wenshao added this to the 2.0.11 milestone Aug 3, 2022
@wsxe9988
Copy link
Contributor

wsxe9988 commented Aug 4, 2022

parems 为{}是不会抛异常,但params=null的时候确实会抛异常

Exception in thread "main" com.alibaba.fastjson.JSONException: error, offset 44, char �
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:197)
	at com.zhuoyun.test3.TestMain.main(TestMain.java:13)
Caused by: com.alibaba.fastjson2.JSONException: error, offset 44, char �
	at com.alibaba.fastjson2.JSONReaderUTF16.skipValue(JSONReaderUTF16.java:2264)
	at com.alibaba.fastjson2.reader.ObjectReaderBean.processExtra(ObjectReaderBean.java:47)
	at com.alibaba.fastjson2.reader.ObjectReader3.readObject(ObjectReader3.java:311)
	at com.alibaba.fastjson.JSON.parseObject(JSON.java:187)
	... 1 more
Exception in thread "main" com.alibaba.fastjson2.JSONException: illegal character �, offset 44, character �, line 1, column 45, fastjson-version 2.0.10 {"wx_id":"xxx","success":true,"parems":null}
	at com.alibaba.fastjson2.JSONReaderUTF16.readFieldNameHashCode(JSONReaderUTF16.java:793)
	at com.alibaba.fastjson2.reader.ObjectReader3.readObject(ObjectReader3.java:265)
	at com.alibaba.fastjson2.JSON.parseObject(JSON.java:453)
	at com.zhuoyun.test3.TestMain.main(TestMain.java:13)

@wenshao

@wenshao
Copy link
Member

wenshao commented Aug 4, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.11-SNAPSHOT/
问题已修复,请用2.0.11-SNAPSHOT版本帮忙验证,2.0.11版本预计在8月7日发布

@wenshao
Copy link
Member

wenshao commented Aug 7, 2022

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

@wenshao wenshao closed this as completed Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants