验证中...
gistfile1.txt
Raw Copy
@Bean("jackson2ObjectMapperBuilderCustomizer")
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
Jackson2ObjectMapperBuilderCustomizer customizer = new Jackson2ObjectMapperBuilderCustomizer() {
@Override
public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
System.out.println("serializerByType");
jacksonObjectMapperBuilder.serializerByType(BigDecimal.class, new JsonSerializer<Object>() {
@Override
public void serialize(Object arg0, JsonGenerator arg1, SerializerProvider arg2)
throws IOException, JsonProcessingException {
if(arg0 instanceof BigDecimal) {
if(arg1 != null) {
arg1.writeString(((BigDecimal) arg0).toPlainString());
}
}
}
});
}
};
return customizer;
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search