fastjson 属性大写问题
发布时间:2020-12-16 19:33:28 所属栏目:百科 来源:网络整理
导读:问题: fastjson 的属性默认是首字母小写的驼峰式分隔, 所以如果首字母是大写的话生成的json 串 有大写的也有小写的(小写是不要的) {" BPM ": 120 ," bPM ": 120 ," x ": 9 } 解决: 在其get 方法前声明下 @JSONField(name = “BPM”) 相当于重命名了 {"
问题:fastjson 的属性默认是首字母小写的驼峰式分隔, 所以如果首字母是大写的话生成的json 串 有大写的也有小写的(小写是不要的) {"BPM":120,"bPM":120,"x":9}
解决:在其get 方法前声明下 {"BPM":120,"x":9}
代码:public class TargetPoint implements Serializable{
public int x;
public int BPM;
public TargetPoint() {
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
@JSONField(name = "BPM")
public int getBPM() {
return BPM;
}
public void setBPM(int BPM) {
this.BPM = BPM;
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |