com.base4j.mvc.conf.JacksonCustomObjectMapper Maven / Gradle / Ivy
package com.base4j.mvc.conf;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
public class JacksonCustomObjectMapper extends ObjectMapper {
private static final long serialVersionUID = 1L;
public JacksonCustomObjectMapper() {
super();
configToStringSerializer();
this.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// // 转换对象为空输出空字符, 避免页面出现null
// this.getSerializerProvider().setNullValueSerializer(new JsonSerializer