Jackson Configuration
The Jackson ObjectMapper
can be configured through configuration with the JacksonConfiguration class.
All Jackson configuration keys start with jackson
.
dateFormat | String | The date format |
locale | String | Uses Locale.forLanguageTag. Example: |
timeZone | String | Uses TimeZone.getTimeZone. Example: |
serializationInclusion | String | One of JsonInclude.Include. Example: |
propertyNamingStrategy | String | Name of an instance of PropertyNamingStrategy. Example: |
defaultTyping | String | The global defaultTyping for polymorphic type handling from enum ObjectMapper.DefaultTyping. Example: |
Example:
jackson:
serializationInclusion: ALWAYS
Features
All features can be configured with their name as the key and a boolean to indicate enabled or disabled.
serialization | Map | |
deserialization | Map | |
mapper | Map | |
parser | Map | |
generator | Map |
Example:
jackson:
serialization:
indentOutput: true
writeDatesAsTimestamps: false
deserialization:
useBigIntegerForInts: true
failOnUnknownProperties: false
Support for @JsonView
You can use the @JsonView
annotation on controller methods if you set jackson.json-view.enabled
to true
in application.yml
.
Jackson’s @JsonView
annotation lets you control which properties are exposed on a per-response basis. See Jackson JSON Views for more information.
Beans
In addition to configuration, beans can be registered to customize Jackson. All beans that extend any of the following classes are registered with the object mapper:
Service Loader
Any modules registered via the service loader are also added to the default object mapper.