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] parsing ['1'] , ["1.1"] #3276

Open
Cooper-Zhong opened this issue Jan 14, 2025 · 0 comments
Open

[BUG] parsing ['1'] , ["1.1"] #3276

Cooper-Zhong opened this issue Jan 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Cooper-Zhong
Copy link
Contributor

问题描述

Integer和Long类型的 ["123"] 可以解析,Double无法解析,Character会只保留[

环境信息

  • OS信息: [e.g.:MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [e.g.:Openjdk 17.0.6]
  • 版本信息:[e.g.:Fastjson2 2.0.54]
    @Test
    public void jsonSerializationTest3() {
        String json = "{\n" +
                "    \"c\":[\"1.1\"]\n" +
                "}";

        Bean bean = JSON.parseObject(json, Bean.class);
        // com.alibaba.fastjson2.JSONException: can not cast to decimal
        System.out.println(bean.getC());
    }
    
    @Test
    public void jsonSerializationTest2() {
        String json = "{\n" +
                "    \"b\":['1']\n" +
                "}";
        Bean bean = JSON.parseObject(json, Bean.class);
        System.out.println(bean.getB()); // [
    }
    @Data
    public static class Bean {
        private Character b;
        private Double c;
    }
@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant