josn的格式化

  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);
}

  

上一篇:r.js打包


下一篇:崽崽帮www.zaizaibang.com精选14