public class JsonUtils {标签:mapping,SerializeConfig,Json,put,new,工具,config,class From: https://www.cnblogs.com/ltf-1225598993/p/17373407.html
private static SerializeConfig mapping = createConfig();
public JsonUtils() {
}
private static SerializeConfig createConfig() {
SerializeConfig config = new SerializeConfig();
config.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
config.put(Timestamp.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
config.put(java.sql.Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
config.put(Double.class, new DoubleSerializer("#.########"));
config.put(BigDecimal.class, new BigDecimalCodec());
return config;
}
public static String toJson(Object paramMap) {
if (null == mapping) {
mapping = createConfig();
}
return JSON.toJSONString(paramMap, mapping, new SerializerFeature[]{SerializerFeature.WriteBigDecimalAsPlain, SerializerFeature.WriteMapNullValue});
}
}