public class JSONFieldDefaultValueTest extends TestCase {
public void test_default_value() throws Exception {
Model m = new Model();
String s = JSON.toJSONString(m);
JSONObject jsonObject = JSON.parseObject(s);
assertEquals(888, jsonObject.get("integer"));
}
public static class Model {
@JSONField(defaultValue = "888")
private Integer integer;
public Model(Integer integer) {
this.integer = integer;
}
public Model() {
}
public Integer getInteger() {
return integer;
}
public void setInteger(Integer integer) {
this.integer = integer;
}
}
}
- 使用defalutValue后没有将序列化后的类型转换成对应javaBean属性的类型
@see com.alibaba.fastjson.serializer.JavaBeanSerializer.java#write Line(320:25)
in master branch
暂无答案!
目前还没有任何答案,快来回答吧!