com.github.xphsc.json.JSONHelper Maven / Gradle / Ivy
package com.github.xphsc.json;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
/**
* Created by ${huipei.x} on 2017-6-1.
*/
public class JSONHelper extends JSON {
public static ValueFilter valueFilter=new JSONValueFilter();
public static final SerializerFeature[] features = {
SerializerFeature.WriteDateUseDateFormat,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.PrettyFormat,
};
public static String toJSON(Object target) {
return JSONHelper.toJSONString(target, valueFilter, features);
}
public static String toJSON(Object target, String dateFormat) {
JSONHelper.DEFFAULT_DATE_FORMAT = dateFormat;
return JSONHelper.toJSONString(target, valueFilter, features);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy