Java Code Examples for org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#featuresToEnable()
The following examples show how to use
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#featuresToEnable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JacksonConfig.java From bearchoke with Apache License 2.0 | 5 votes |
@Bean public ObjectMapper objectMapper() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); builder.featuresToDisable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS ); builder.featuresToEnable( SerializationFeature.WRITE_DATES_WITH_ZONE_ID, // SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, // SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, // DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT ); builder.indentOutput(true); builder.failOnEmptyBeans(false); builder.failOnUnknownProperties(false); // do not include null value in json to make object graph smaller builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.modules(new GeoJsonModule(), new JavaTimeModule(), new MoneyModule()); return builder.build(); }
Example 2
Source File: MockServerConfig.java From bearchoke with Apache License 2.0 | 5 votes |
@Bean(name = "customObjectMapper") public ObjectMapper customObjectMapper() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); builder.featuresToDisable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS ); builder.featuresToEnable( SerializationFeature.WRITE_DATES_WITH_ZONE_ID, // SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, // SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, // DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT ); builder.indentOutput(true); builder.failOnEmptyBeans(false); builder.failOnUnknownProperties(false); // do not include null value in json to make object graph smaller builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.modules(new GeoJsonModule(), new JavaTimeModule(), new MoneyModule()); return builder.build(); }