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] Feature.InitStringFieldAsEmpty无法将null值反序列化为""空字符串 #1128

Closed
human-user opened this issue Feb 20, 2023 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@human-user
Copy link

问题描述

如题

环境信息

请填写以下信息:

  • OS信息: Win10
  • JDK信息: corretto-17.0.6
  • 版本信息:2.0.23

重现步骤

示例:

@Getter
@Setter
public class Test {

    private String code;
    private String name;

    public static void main(String[] args) {
        Test test1 = JSON.parseObject("{\"code\": \"test\",\"name\": null}", Test.class, Feature.InitStringFieldAsEmpty);
        System.out.println(test1.getCode());
        System.out.println(test1.getName());

        Test test2 = JSON.parseObject("{\"code\": \"test\"}", Test.class, Feature.InitStringFieldAsEmpty);
        System.out.println(test2.getCode());
        System.out.println(test2.getName());
    }
}

输出:

test
null
test
null

期待的正确结果

输出:

test

test

相关日志输出

附加信息

@human-user human-user added the bug Something isn't working label Feb 20, 2023
@wenshao wenshao added this to the 2.0.25 milestone Feb 20, 2023
@wenshao
Copy link
Member

wenshao commented Feb 22, 2023

这个有点麻烦,要稍晚一点

wenshao added a commit that referenced this issue Feb 23, 2023
wenshao added a commit that referenced this issue Feb 23, 2023
@wenshao
Copy link
Member

wenshao commented Feb 27, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.25-SNAPSHOT/
问题已修复,请帮忙用2.0.25-SNAPSHOT版本验证,2.0.25版本预计在3月中旬发布。

@human-user
Copy link
Author

2.0.25-SNAPSHOT版本,使用示例进行测试,目前打印如下:

test
null
test

@wenshao 对于 "{\"code\": \"test\",\"name\": null}" 这种情况,不考虑将null转换为空字符串?

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