Set Jackson DEFAULT_VIEW_INCLUSION property to false by default
Issue: SPR-12179
This commit is contained in:
@@ -47,6 +47,12 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* A builder used to create {@link ObjectMapper} instances with a fluent API.
|
||||
*
|
||||
* <p>It customizes Jackson defaults properties with the following ones:
|
||||
* <ul>
|
||||
* <li>{@link MapperFeature#DEFAULT_VIEW_INCLUSION} is disabled</li>
|
||||
* <li>{@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES} is disabled</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note that Jackson's JSR-310 and Joda-Time support modules will be registered automatically
|
||||
* when available (and when Java 8 and Joda-Time themselves are available, respectively).
|
||||
*
|
||||
@@ -384,6 +390,9 @@ public class Jackson2ObjectMapperBuilder {
|
||||
this.objectMapper.registerModule(module);
|
||||
}
|
||||
|
||||
if(!features.containsKey(MapperFeature.DEFAULT_VIEW_INCLUSION)) {
|
||||
configureFeature(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
}
|
||||
if(!features.containsKey(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) {
|
||||
configureFeature(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,12 @@ import org.springframework.util.ClassUtils;
|
||||
* {@link XmlMapper} ({@code createXmlMapper} property set to true) with setters
|
||||
* to enable or disable Jackson features from within XML configuration.
|
||||
*
|
||||
* <p>It customizes Jackson defaults properties with the following ones:
|
||||
* <ul>
|
||||
* <li>{@link MapperFeature#DEFAULT_VIEW_INCLUSION} is disabled</li>
|
||||
* <li>{@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES} is disabled</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Example usage with
|
||||
* {@link MappingJackson2HttpMessageConverter}:
|
||||
*
|
||||
@@ -413,6 +419,9 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
|
||||
this.objectMapper.registerModule(module);
|
||||
}
|
||||
|
||||
if(!features.containsKey(MapperFeature.DEFAULT_VIEW_INCLUSION)) {
|
||||
configureFeature(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
|
||||
}
|
||||
if(!features.containsKey(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) {
|
||||
configureFeature(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user