|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -62,54 +62,54 @@ import org.springframework.lang.Nullable; |
|
|
|
* <p>Example usage with |
|
|
|
* <p>Example usage with |
|
|
|
* {@link MappingJackson2HttpMessageConverter}: |
|
|
|
* {@link MappingJackson2HttpMessageConverter}: |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code">{@code |
|
|
|
* <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> |
|
|
|
* <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> |
|
|
|
* <property name="objectMapper"> |
|
|
|
* <property name="objectMapper"> |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" |
|
|
|
* p:autoDetectFields="false" |
|
|
|
* p:autoDetectFields="false" |
|
|
|
* p:autoDetectGettersSetters="false" |
|
|
|
* p:autoDetectGettersSetters="false" |
|
|
|
* p:annotationIntrospector-ref="jaxbAnnotationIntrospector" /> |
|
|
|
* p:annotationIntrospector-ref="jaxbAnnotationIntrospector" /> |
|
|
|
* </property> |
|
|
|
* </property> |
|
|
|
* </bean> |
|
|
|
* </bean> |
|
|
|
* </pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Example usage with MappingJackson2JsonView: |
|
|
|
* <p>Example usage with MappingJackson2JsonView: |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code">{@code |
|
|
|
* <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"> |
|
|
|
* <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"> |
|
|
|
* <property name="objectMapper"> |
|
|
|
* <property name="objectMapper"> |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" |
|
|
|
* p:failOnEmptyBeans="false" |
|
|
|
* p:failOnEmptyBeans="false" |
|
|
|
* p:indentOutput="true"> |
|
|
|
* p:indentOutput="true"> |
|
|
|
* <property name="serializers"> |
|
|
|
* <property name="serializers"> |
|
|
|
* <array> |
|
|
|
* <array> |
|
|
|
* <bean class="org.mycompany.MyCustomSerializer" /> |
|
|
|
* <bean class="org.mycompany.MyCustomSerializer" /> |
|
|
|
* </array> |
|
|
|
* </array> |
|
|
|
* </property> |
|
|
|
* </property> |
|
|
|
* </bean> |
|
|
|
* </bean> |
|
|
|
* </property> |
|
|
|
* </property> |
|
|
|
* </bean> |
|
|
|
* </bean> |
|
|
|
* </pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>In case there are no specific setters provided (for some rarely used options), |
|
|
|
* <p>In case there are no specific setters provided (for some rarely used options), |
|
|
|
* you can still use the more general methods {@link #setFeaturesToEnable} and |
|
|
|
* you can still use the more general methods {@link #setFeaturesToEnable} and |
|
|
|
* {@link #setFeaturesToDisable}. |
|
|
|
* {@link #setFeaturesToDisable}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code">{@code |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"> |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"> |
|
|
|
* <property name="featuresToEnable"> |
|
|
|
* <property name="featuresToEnable"> |
|
|
|
* <array> |
|
|
|
* <array> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRAP_ROOT_VALUE"/> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.WRAP_ROOT_VALUE"/> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.CLOSE_CLOSEABLE"/> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.SerializationFeature.CLOSE_CLOSEABLE"/> |
|
|
|
* </array> |
|
|
|
* </array> |
|
|
|
* </property> |
|
|
|
* </property> |
|
|
|
* <property name="featuresToDisable"> |
|
|
|
* <property name="featuresToDisable"> |
|
|
|
* <array> |
|
|
|
* <array> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.USE_ANNOTATIONS"/> |
|
|
|
* <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.USE_ANNOTATIONS"/> |
|
|
|
* </array> |
|
|
|
* </array> |
|
|
|
* </property> |
|
|
|
* </property> |
|
|
|
* </bean> |
|
|
|
* </bean> |
|
|
|
* </pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>It also automatically registers the following well-known modules if they are |
|
|
|
* <p>It also automatically registers the following well-known modules if they are |
|
|
|
* detected on the classpath: |
|
|
|
* detected on the classpath: |
|
|
|
@ -119,7 +119,7 @@ import org.springframework.lang.Nullable; |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>: |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>: |
|
|
|
* support for other Java 8 types like {@link java.util.Optional}</li> |
|
|
|
* support for other Java 8 types like {@link java.util.Optional}</li> |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>: |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>: |
|
|
|
* support for Java 8 Date & Time API types</li> |
|
|
|
* support for Java 8 Date & Time API types</li> |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>: |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>: |
|
|
|
* support for Joda-Time types</li> |
|
|
|
* support for Joda-Time types</li> |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>: |
|
|
|
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>: |
|
|
|
@ -129,11 +129,11 @@ import org.springframework.lang.Nullable; |
|
|
|
* <p>In case you want to configure Jackson's {@link ObjectMapper} with a custom {@link Module}, |
|
|
|
* <p>In case you want to configure Jackson's {@link ObjectMapper} with a custom {@link Module}, |
|
|
|
* you can register one or more such Modules by class name via {@link #setModulesToInstall}: |
|
|
|
* you can register one or more such Modules by class name via {@link #setModulesToInstall}: |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code">{@code |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"> |
|
|
|
* <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"> |
|
|
|
* <property name="modulesToInstall" value="myapp.jackson.MySampleModule,myapp.jackson.MyOtherModule"/> |
|
|
|
* <property name="modulesToInstall" value="myapp.jackson.MySampleModule,myapp.jackson.MyOtherModule"/> |
|
|
|
* </bean |
|
|
|
* </bean |
|
|
|
* </pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3. |
|
|
|
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3. |
|
|
|
* |
|
|
|
* |
|
|
|
|