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] Parse decimal point number with suffix L #2768

Closed
Cooper-Zhong opened this issue Jul 2, 2024 · 1 comment
Closed

[BUG] Parse decimal point number with suffix L #2768

Cooper-Zhong opened this issue Jul 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@Cooper-Zhong
Copy link
Contributor

问题描述

{"value": 1.23L}整体会解析为long,得到123

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson2 2.0.51]

重现步骤

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.junit.jupiter.api.Test;

public class Test_1041 {
    @Test
    public void test() {
        String jsonStr = "{\"value\": 1.23L}";
        JSONObject jsonObject = JSON.parseObject(jsonStr);
        Long result1 = jsonObject.getLong("value");
        Float result2 = jsonObject.getFloat("value");
        String result3 = jsonObject.getString("value");
        System.out.println(result1);
        System.out.println(result2);
        System.out.println(result3);
    }
}

相关日志输出

fastjson 1.x:
1
1.23
1.23

fastjson2 2.0.51:
123
123.0
123

@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label Jul 2, 2024
@Cooper-Zhong Cooper-Zhong changed the title [BUG] Parse value like 1.23L will get 123 [BUG] Parse decimal point number with suffix L Jul 2, 2024
@yanxutao89 yanxutao89 self-assigned this Jul 2, 2024
@wenshao wenshao added this to the 2.0.52 milestone Jul 3, 2024
@wenshao wenshao added the fixed label Jul 7, 2024
@wenshao
Copy link
Member

wenshao commented Jul 14, 2024

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

@wenshao wenshao closed this as completed Jul 14, 2024
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

3 participants