JsonMapperBuilderCustomizer class abstract interface

A bean that adjusts the auto-configured ObjectMapper while keeping everything else about it.

Declaring your own ObjectMapper replaces the auto-configured one completely, spring.json.* properties included. A customizer instead changes one thing on the builder: a setting that has no property, or a module that should only be added in some cases. Customizers run after the properties are applied, in @Order order, so they win over the properties.

// The partner API expects snake_case, whatever the properties say.
@Bean()
JsonMapperBuilderCustomizer snakeCase() => JsonMapperBuilderCustomizer.of(
  (builder) =>
      builder.propertyNamingStrategy(PropertyNamingStrategy.snakeCase),
);

Spring (Java):

@Bean
JsonMapperBuilderCustomizer snakeCase() {
  return builder -> builder.propertyNamingStrategy(
      PropertyNamingStrategies.SNAKE_CASE);
}

Constructors

JsonMapperBuilderCustomizer.of(void customize(JsonMapperBuilder builder))
A customizer that runs customize; the short form for a @Bean method.
const
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

customize(JsonMapperBuilder builder) → void
Changes builder before the mapper is built. Called once, when the ObjectMapper bean is created.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited