public class Test {
public static void main(String[] args) {
TestModel testModel = new TestModel();
testModel.setDesc(null);
System.out.println(JSON.toJSONString(testModel, SerializerFeature.WriteNullStringAsEmpty));
}
static class TestModel {
String desc;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
}
实验输出结果为:{}
1条答案
按热度按时间slwdgvem1#
之前需要结合WriteMapNullValue才能生效,升级到最新版本吧,比如1.2.30就好了