Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG]首字母大写字段无法parse #983

Closed
shijiebei2009 opened this issue Dec 1, 2022 · 3 comments
Closed

[BUG]首字母大写字段无法parse #983

shijiebei2009 opened this issue Dec 1, 2022 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@shijiebei2009
Copy link

shijiebei2009 commented Dec 1, 2022

问题描述

简要描述您碰到的问题。
首字母大写字段无法parse。fastjson1.0可以支持,大家切换2.0一定要甚重,不建议切换不建议切换。

环境信息

请填写以下信息:

  • OS信息: [Windows/Linux]
  • JDK信息: [JDK17]
  • 版本信息:[Fastjson2 2.0.20]

重现步骤

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

  1. 使用 xxx.xxx 方法
  2. 输入 ... 数据
  3. 出现 ... 错误
@Test
public void test2() {
    String s = "{\"OneDemo\":\"1\",\"TDemo\":\"2\",\"ThDemo\":\"3\"}";
    TestModel testModel = JSON.parseObject(s, TestModel.class);
    System.out.println(testModel);
}

@Setter
class TestModel {
    private String OneDemo;

    private String TDemo;

    private String ThDemo;

    @Override
    public String toString() {
        return "TestModel{" + "OneDemo='" + OneDemo + '\'' + ", TDemo='" + TDemo + '\'' + ", ThDemo='" + ThDemo + '\'' + '}';
    }
}

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
期望parse成功

相关日志输出

请复制并粘贴任何相关的日志输出。
TestModel{OneDemo='null', TDemo='2', ThDemo='null'}

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@shijiebei2009 shijiebei2009 added the bug Something isn't working label Dec 1, 2022
@wenshao
Copy link
Member

wenshao commented Dec 1, 2022

JSONReader.Feature.SupportSmartMatch 用这个可以自动识别

TestModel testModel = JSON.parseObject(s, TestModel.class, JSONReader.Feature.SupportSmartMatch);

@wenshao
Copy link
Member

wenshao commented Dec 1, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.21-SNAPSHOT/
问题已修复,不用加JSONReader.Feature.SupportSmartMatch,可以直接支持,请帮用快照版本验证

@wenshao wenshao added this to the 2.0.21 milestone Dec 1, 2022
@wenshao wenshao added the fixed label Dec 1, 2022
@wenshao
Copy link
Member

wenshao commented Dec 10, 2022

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

@wenshao wenshao closed this as completed Dec 10, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants