8
1.2.71-1.2.73 get__password() 通过 JSON.toJSONString 转为了 password 而不是在 1.2.61 及以下转为 _password
测试用例:
public class Test2JSONString {
public static void main(String[] args) {
System.out.println(JSON.toJSONString(new Privacy().setPassword("test")));
}
}
class Privacy {
private String phone; //手机
private String password; //登录密码,隐藏字段
public Privacy() {
super();
}
public String getPhone() {
return phone;
}
public Privacy setPhone(String phone) {
this.phone = phone;
return this;
}
public String get__password() {
return password;
}
public Privacy setPassword(String password) {
this.password = password;
return this;
}
}
解决方法: 用 @JSONField 指定序列化后的 JSON key 名
@JSONField(name="_password")
public String get__password() {
return password;
}