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]单引号反序列化时,无法忽略大小写匹配 #3381

Closed
1277121822 opened this issue Mar 12, 2025 · 2 comments
Closed

[BUG]单引号反序列化时,无法忽略大小写匹配 #3381

1277121822 opened this issue Mar 12, 2025 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@1277121822
Copy link

1277121822 commented Mar 12, 2025

问题描述

单引号反序列化时,无法忽略大小写匹配。

环境信息

请填写以下信息:

  • OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.54]

重现步骤

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

  1. 使用 JSON.parseObject(jsonStr2, JSONField2VO.class,JSONReader.Feature.SupportSmartMatch)方法
  2. 输入 { 'user_NAme': "xxx", "age": "xx"} 数据
  3. 出现 字段name值为null 错误
        String jsonStr2 = "{    'user_Name': \"xxx\",    \"age\": \"xx\"}";
        // 1.x版本
        JSONField1VO jsonField1VO2 = com.alibaba.fastjson.JSON.parseObject(jsonStr2, JSONField1VO.class);
        // 2.x版本
        JSONField2VO jsonField2VO2 = JSON.parseObject(jsonStr2, JSONField2VO.class,JSONReader.Feature.SupportSmartMatch);

        assertNotNull(jsonField1VO2.getName());
        assertNotNull(jsonField2VO2.getName());

JSONField2VO.java如下:

import com.alibaba.fastjson2.annotation.JSONField;

import lombok.Data;

@Data
public class JSONField2VO {
    
    @JSONField(name = "user_name")
    private String name;

    private String age;
    
}

期待的正确结果

在使用单引号的情况下,忽略大小写也应生效

相关日志输出

附加信息

@1277121822 1277121822 added the bug Something isn't working label Mar 12, 2025
@wenshao wenshao added this to the 2.0.57 milestone Mar 13, 2025
@wenshao wenshao added the fixed label Mar 13, 2025
@1277121822
Copy link
Author

ok~

@wenshao
Copy link
Member

wenshao commented Mar 31, 2025

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

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