//package com.safeluck.aaej.app.config;
|
//
|
//import com.fasterxml.jackson.annotation.JsonInclude;
|
//import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
//import com.fasterxml.jackson.databind.DeserializationFeature;
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
//import com.fasterxml.jackson.databind.SerializationFeature;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
//import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Primary;
|
//import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
//
|
//import java.text.SimpleDateFormat;
|
//
|
//@Configuration
|
//public class JacksonConfig
|
//{
|
// @Bean
|
// @Primary
|
//// @ConditionalOnMissingBean(ObjectMapper.class)
|
// public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
|
// {
|
// ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
//
|
// //设置null值不参与序列化(字段不被显示)
|
// objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
//
|
// // 禁用空对象转换json校验
|
// objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
//// this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
// objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
// objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
//// this.enableDefaultTyping();
|
//// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
//// this.configure(SerializationFeature.CLOSE_CLOSEABLE);
|
// objectMapper.enable(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN);
|
// objectMapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
|
//
|
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
//
|
// objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
// objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
//
|
// return objectMapper;
|
// }
|
//}
|
//
|
//
|