ObjectMapper in Jackson is the class that binds JSON to Java types and back. It is the main entry point of the jackson-databind module: it holds the configuration, registers modules, and creates the readers and writers that do the actual work. Spring Boot, Quarkus and many other frameworks build their JSON support on top of it.
This article focuses on how ObjectMapper fits into Jackson's architecture, how Spring Boot exposes it, and what changes in Jackson 3.
Jackson is split into modules:
| Module | Role |
|---|---|
jackson-core | Streaming parser and generator (JsonParser, JsonGenerator) |
jackson-annotations | Annotations such as @JsonProperty and @JsonIgnore |
jackson-databind | ObjectMapper, data binding and the tree model |
| Data type modules | jackson-datatype-jsr310 for java.time, jackson-datatype-jdk8 for Optional, and others |
ObjectMapper sits on the databind layer. It uses the streaming API underneath and adds object binding, annotation handling and caching of type information.
readValue and writeValueAsString.JsonNode with readTree when the shape is dynamic.JsonParser and JsonGenerator for very large documents that must not be held in memory.The last line throws UnrecognizedPropertyException because of the extra field, since failing on unknown properties is the default. Disable DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES or add @JsonIgnoreProperties(ignoreUnknown = true) if that is not what you want.
For repeated work with one type, ask the mapper for a pre-configured reader or writer. They are immutable and thread-safe, and they avoid looking up the type each time:
Use reader.with(...) or writer.with(...) to change a feature for a single call without touching the shared mapper.
Spring Boot auto-configures a single ObjectMapper bean through JacksonAutoConfiguration and uses it for @RestController request and response bodies. Customize it through properties or a customizer bean instead of building your own, so that MVC and your code share the same rules:
Boot also registers modules found on the classpath, including the Java time and Optional modules. If you declare your own ObjectMapper bean, auto-configuration backs off for that bean, and settings from spring.jackson.* no longer apply to it unless you build it from Jackson2ObjectMapperBuilder.
Since Jackson 2.10, the preferred way to construct a configured mapper is the builder on JsonMapper, which makes the configuration explicit and finished at build time:
Jackson 3 is a major release with a new base package, tools.jackson, for the core and databind modules, while the annotations remain in com.fasterxml.jackson.annotation. In it, mappers are immutable and built only through builders, and the Java time support is part of the databind module. Spring Boot 4 builds on Jackson 3, so check which Jackson major version your Spring Boot version uses before copying code. Jackson 2.x remains widely used, and the examples above apply to it.
@JsonSubTypes or a PolymorphicTypeValidator.BigDecimal for money and consider USE_BIG_DECIMAL_FOR_FLOATS when parsing into generic structures.Usually no. Use the auto-configured one and customize it with properties or a builder customizer, so your code and the web layer behave the same.
JsonMapper is the JSON-specific subclass of ObjectMapper. It offers a builder and is the recommended way to create a mapper in Jackson 2.10 and later.
Yes, through subclasses in other modules, such as XmlMapper and YAMLMapper, which share the same API.
Call mapper.readValue(json, new TypeReference<Map<String, Object>>() {}).
ObjectMapper is Jackson's databind entry point, built on the streaming core. Configure one instance, reuse it, derive readers and writers for hot paths, let Spring Boot manage the shared bean, and be aware that Jackson 3 changes packages and makes mappers immutable.