美文网首页
对象转JSONObject——字段空值不显示处理办法

对象转JSONObject——字段空值不显示处理办法

作者: 蜻蜓队长家长 | 来源:发表于2021-07-21 16:13 被阅读0次

一、引包

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.71</version>
</dependency>

二、使用toJSONString()

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

String s = JSONObject.toJSONString(对象,SerializerFeature.WriteMapNullValue);

相关文章

网友评论

      本文标题:对象转JSONObject——字段空值不显示处理办法

      本文链接:https://www.haomeiwen.com/subject/tumjmltx.html