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] 当在对象double属性上加上@JSONField(format="#.##") ,赋值NaN序列化出来不是null #1562

Closed
Merely-chao opened this issue Jun 14, 2023 · 1 comment
Labels
bug Something isn't working fixed
Milestone

Comments

@Merely-chao
Copy link

问题描述

当在对象double属性上加上@JSONField(format="#.##") NaN序列化出来不是null

环境信息

请填写以下信息:

  • OS信息: [e.g.:win11]
  • JDK信息: [e.g.:Openjdk 17]
  • 版本信息:[e.g.:Fastjson2 2.0.33]

重现步骤

如何操作可以重现该问题:

	@Data
    class Cs {


        @JSONField(format = "#.##")
        private double value = Double.NaN;


    }

    @Test
    void test() {

        Cs s = new Cs();
        var tt = JSON.toJSONString(s);

        System.out.println(tt);


    }

输出结果

{"value":NaN}

期待的正确结果

希望输出:

{"value":null}
@Merely-chao Merely-chao added the bug Something isn't working label Jun 14, 2023
yanxutao89 added a commit to yanxutao89/fastjson2 that referenced this issue Jun 14, 2023
@wenshao wenshao added this to the 2.0.34 milestone Jun 18, 2023
@wenshao wenshao added the fixed label Jun 18, 2023
@wenshao
Copy link
Member

wenshao commented Jun 18, 2023

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

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