fastjson v1.2.37到v1.2.44 反序列化成自定义类对象时,Double、Float类型的变量会自动初始化为0.0(json字符串对应值为null)

jyztefdp  于 2021-11-27  发布在  Java
关注(0)|答案(4)|浏览(325)

sonStr={"age":null,"ftest1":null,"id":null,"name":null,"test1":null,"test2":null}

类:
public class Person implements Serializable {
private String id;
private String name;
private Integer age;
private Double test1;
private Double test2;
private Float ftest1;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

public Double getTest1() {
return test1;
}

public void setTest1(Double test1) {
this.test1 = test1;
}

public Double getTest2() {
return test2;
}

public void setTest2(Double test2) {
this.test2 = test2;
}

public Float getFtest1() {
return ftest1;
}

public void setFtest1(Float ftest1) {
this.ftest1 = ftest1;
}
}

反序列化后 test1=0.0, test2=0.0, ftest=0.0

这不太合理吧,确认下这个是bug还是增加的新特性

5us2dqdw

5us2dqdw2#

测试了一下是1.2.37之后都这样

muk1a3rh

muk1a3rh3#

我也刚刚遇到了。

oyxsuwqo

oyxsuwqo4#

我也发现这个问题了。 1.2.47也是。

相关问题