public String formatJson(Object obj) { com.alibaba.fastjson.JSONObject json=(com.alibaba.fastjson.JSONObject)JSON.toJSON(obj); //定制序列化 SerializeFilter[] filter = new SerializeFilter[]{ new ValueFilter() { @Override public Object process(Object object, String name, Object value) { if (value == null || value == "") { return ""; } return value; } } }; return JSON.toJSONString(json, filter, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteDateUseDateFormat); }