-
Notifications
You must be signed in to change notification settings - Fork 510
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]CamelCase has some problems #546
Comments
fastjson v1 is use reflect to solve fields name, but fastjson2 is use gettername to solve fields name. so i think need to use CamelCase definition to make obvious distinction. |
@Test
public void test1() {
B vo = new B();
vo.cId = "2";
assertEquals("{\"cId\":\"2\"}", JSON.toJSONString(vo));
}
public static class B {
public String uId;
public String cId;
} 你可以通过把field声明为public就可以解决这个问题 |
public static void main(String[] args) {
A a = new A();
a.setUId("a");
System.out.println(JSON.toJSONString(a));
// SpringApplication.run(DemoApplication.class, args);
}
@Data
static public class A {
// @JSONField(name = "uid")
public String uId;
} 如果加上get set方法 |
@Test
public void test2() {
assertEquals("abc", JSON.parseObject("{\"uId\":\"abc\"}", C.class).uId);
assertEquals("abc", JSON.parseObject("{\"UId\":\"abc\"}", C.class).uId);
}
public static class C {
private String uId;
public String getUId() {
return uId;
}
public void setUId(String uId) {
this.uId = uId;
}
} 最新快照版本反序列化已经能支持自动识别多种输入 |
https://github.com/alibaba/fastjson2/releases/tag/2.0.13 |
问题描述
简要描述您碰到的问题。
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
BeanUtils.getterName
方法UId
数据UId
错误期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
//{"cId":"2"}
相关日志输出
请复制并粘贴任何相关的日志输出。
{"CId":"2"}
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: