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

反序列化特定格式的字段时失败 #743

Closed
WuChenYangJava opened this issue Sep 8, 2022 · 2 comments
Closed

反序列化特定格式的字段时失败 #743

WuChenYangJava opened this issue Sep 8, 2022 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@WuChenYangJava
Copy link

问题描述

我的类中有一些字段是由一个英文字母和另一个单词组成,按照标准驼峰命名
例如:vSpeed
当我使用JSON.parseObject方法将json字符串中该字段反序列到实体类时,总是不能成功将值映射到实体类中

环境信息

请填写以下信息:

  • OS信息: Windows 10 家庭中文版 21H2 16Core 3.3GHz 16GB
  • JDK信息: Oracle JDK 1.8.0_202
  • 版本信息:Fastjson 2.0.3

重现步骤

1、新建一个类,添加由一个英文字母和另一个单词组成的实体类字段,eg: xSpeed
2、准备对应该实体类字段的json字符串,eg: {"xSpeed":999.999}
3、使用JSON.parseObjec()方法反序列化该json字符串到实体类中,然后输出该实体类的字段发现没有成功赋值
实例代码如下:
public static void main(String[] args) throws Exception{
String json = "{"xSpeed":20.7,"aName":"bug"}";
Test t = JSON.parseObject(json, Test.class);
System.out.println(t.getXSpeed());
System.out.println(t.getAName());
}

static class Test{
    private float xSpeed;
    private String aName;

    public float getXSpeed() {
        return xSpeed;
    }

    public void setXSpeed(float xSpeed) {
        this.xSpeed = xSpeed;
    }

    public String getAName() {
        return aName;
    }

    public void setAName(String aName) {
        this.aName = aName;
    }
}

期待的正确结果

能够正常将字段值设置到实体类中

相关日志输出

请复制并粘贴任何相关的日志输出。

附加信息

image
image

@WuChenYangJava WuChenYangJava added the bug Something isn't working label Sep 8, 2022
@wenshao
Copy link
Member

wenshao commented Sep 9, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.13-SNAPSHOT/
问题已经修复,请用2.0.13-SNAPSHOT版本帮忙验证,2.0.13版本预计9月12日发布

@wenshao wenshao added this to the 2.0.13 milestone Sep 9, 2022
@wenshao
Copy link
Member

wenshao commented Sep 10, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.13
2.0.13版本已经发布,请用帮忙用新版本验证

@wenshao wenshao closed this as completed Sep 10, 2022
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

2 participants