Jackson Configuration

The Jackson ObjectMapper can be configured through normal configuration with the JacksonConfiguration class.

All jackson configuration keys start with jackson.

dateFormat

String

The date format

locale

String

Uses Locale.forLanguageTag. Example: en-US

timeZone

String

Uses TimeZone.getTimeZone. Example: PST

serializationInclusion

String

One of JsonInclude.Include. Example: ALWAYS

propertyNamingStrategy

String

Name of an instance of PropertyNamingStrategy. Example: SNAKE_CASE

defaultTyping

String

The global defaultTyping for polymorphic type handling from enum ObjectMapper.DefaultTyping. Example: NON_FINAL

Example:

  1. jackson:
  2. serializationInclusion: ALWAYS

Features

All features can be configured with their name as the key and a boolean to indicate enabled or disabled.

serialization

Map

SerializationFeature

deserialization

Map

DeserializationFeature

mapper

Map

MapperFeature

parser

Map

JsonParser.Feature

generator

Map

JsonGenerator.Feature

Example:

  1. jackson:
  2. serialization:
  3. indentOutput: true
  4. writeDatesAsTimestamps: false
  5. deserialization:
  6. useBigIntegerForInts: true
  7. failOnUnknownProperties: false

Support for @JsonView

You can use the @JsonView annotation to controller methods if you set jackson.json-view.enabled to true in application.yml.

Jackson’s @JsonView annotation allows you to control which properties are exposes 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 will be registered with the object mapper.

Service Loader

Any modules registered via the service loader will also be added to the default object mapper.