一、引包
<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);
网友评论