Skip to content

Deserializer Discovery 2.x

Tatu Saloranta edited this page Jan 29, 2024 · 19 revisions

Discovering Deserializers in Jackson 2.x

This page describes the process of discovering {@code JsonDeserializer}s in Jackson 2.x

General

{@code JsonDeserializer}s are needed for reading JSON (and other supported formats) from {@code JsonParser} and constructing desired Java Objects. Discovery process is initiated by 3 main entities:

  1. ObjectMapper to locate deserializer to use for target type indicated for readValue() method (and readValues(), convertValue())
  2. ObjectReader (similar to ObjectMapper)
  3. Deserializers themselves, to locate "child deserializers": for example when deserializing Lists, deserializer for elements contained is separate from deserializer for List itself (and similarly for other structured types like java.util.Maps, Arrays, POJOs)

Discovery process for these cases is almost identical (and in fact, (1) and (2) are identical), differing only in that for (3), contextualization (via method DeserializationContext._handleSecondaryContextualization(...)) passes referring property definition (BeanProperty) whereas one does not exist for "root" values.

High-level call sequence

Clone this wiki locally