You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
问题描述
fastjson 序列化时,会调用所有get开头并且是驼峰命名的方法,并且是根据get方法去解析对象属性的吗?(是设计如此吗)
User对象没有创建test属性,但是输出结果根据getTest方法解析到了test属性
环境信息
请填写以下信息:
OS信息: window10
JDK信息: 1.8
版本信息:所有版本(fastjson fastjson2)
重现步骤
public static void main(String[] args) {
User user = new User();
user.setName("test");
System.out.println(JSON.toJSONString(user));
}
class User{
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTest(){
System.out.println("测试调用自定义get方法");
return "测试调用自定义get方法";
}
public String getdev(){
System.out.println("测试");
return "测试";
}
}
输出结果
测试调用自定义get方法
{"name":"test","test":"测试调用自定义get方法"}
期待的正确结果
期望只输出对应字段的序列化结果,目前测试了市面上的几款json工具,好像只有fastjson、fastjson2会出现此问题
The text was updated successfully, but these errors were encountered: