use of org.springframework.http.converter.json.Jackson2ObjectMapperBuilder in project spring-boot by spring-projects.
the class JacksonAutoConfigurationTests method defaultObjectMapperBuilder.
@Test
public void defaultObjectMapperBuilder() throws Exception {
this.context.register(JacksonAutoConfiguration.class);
this.context.refresh();
Jackson2ObjectMapperBuilder builder = this.context.getBean(Jackson2ObjectMapperBuilder.class);
ObjectMapper mapper = builder.build();
assertThat(MapperFeature.DEFAULT_VIEW_INCLUSION.enabledByDefault()).isTrue();
assertThat(mapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)).isFalse();
assertThat(MapperFeature.DEFAULT_VIEW_INCLUSION.enabledByDefault()).isTrue();
assertThat(mapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)).isFalse();
assertThat(mapper.getSerializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)).isFalse();
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.enabledByDefault()).isTrue();
assertThat(mapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
}
use of org.springframework.http.converter.json.Jackson2ObjectMapperBuilder in project ocvn by devgateway.
the class MvcConfig method objectMapperBuilder.
@Bean
public Jackson2ObjectMapperBuilder objectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
//builder.featuresToEnable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
builder.serializationInclusion(Include.NON_EMPTY).dateFormat(dateFormatGmt);
builder.serializerByType(GeoJsonPoint.class, new GeoJsonPointSerializer());
builder.serializerByType(ObjectId.class, new ToStringSerializer());
builder.defaultViewInclusion(true);
return builder;
}
Aggregations