【java】JSONString空对象也可以转化为JSON字符串        <dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.23</version>
</dependency>
Student item = new Student();
System.out.println(
item,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullNumberAsZero,
json转换对象
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteNullBooleanAsFalse
)
);
QuoteFieldNames———-输出key时是否使⽤双引号,默认为true
WriteMapNullValue——–是否输出值为null的字段,默认为false
WriteNullNumberAsZero—-数值字段如果为null,输出为0,⽽⾮null
WriteNullListAsEmpty—–List字段如果为null,输出为[],⽽⾮null
WriteNullStringAsEmpty—字符类型字段如果为null,输出为”“,⽽⾮null
WriteNullBooleanAsFalse–Boolean字段如果为null,输出为false,⽽⾮nul

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。