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

Feature.InitStringFieldAsEmpty无法将null值反序列化为""空字符串 #4349

Closed
human-user opened this issue Feb 9, 2023 · 2 comments
Closed

Comments

@human-user
Copy link

human-user commented Feb 9, 2023

版本:1.2.83

示例:

@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

另外在2.0.23版本测试输出结果为:

test
null
test
null
@wenshao
Copy link
Member

wenshao commented Feb 19, 2023

https://github.com/alibaba/fastjson2/issues
可以到这里提issue么?

@human-user
Copy link
Author

https://github.com/alibaba/fastjson2/issues 可以到这里提issue么?

已提

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

2 participants