JsonModule class

A group of serializers and deserializers that is added to a mapper in one step.

Use it to ship the JSON support of a set of types together, for example a library's money and currency types. In Spring Boot every JsonModule bean is added to the auto-configured ObjectMapper, as Boot registers Jackson Module beans; otherwise pass it to ObjectMapper(modules: [...]). Its serializers and deserializers come after those passed to the mapper directly.

// Money support for the whole application.
@Configuration()
class JsonSetup {
  @Bean()
  JsonModule moneyModule() => const JsonModule(
    serializers: [MoneySerializer()],
    deserializers: [MoneyDeserializer()],
  );
}

Spring (Java):

@Bean
Module moneyModule() {
  return new SimpleModule()
      .addSerializer(Money.class, new MoneySerializer())
      .addDeserializer(Money.class, new MoneyDeserializer());
}

Constructors

JsonModule({List<JsonSerializer<Object>> serializers = const [], List<JsonDeserializer<Object>> deserializers = const []})
A module holding serializers and deserializers; both default to none.
const

Properties

deserializers → List<JsonDeserializer<Object>>
The deserializers, tried in order.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serializers → List<JsonSerializer<Object>>
The serializers, tried in order.
final

Methods

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