跪拜 Guibai
← All articles
Backend

Jackson 3 Breaks Everything: New Package, Immutable Mapper, and a Mandatory JDK 17 Floor

By 苏三说技术 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Nearly every Java service that speaks JSON sits on Jackson. Upgrading to Spring Boot 4 forces this migration, and the breaking changes — new imports, locked configuration, different date formats — will hit every serialization path in a codebase at once.

Summary

Jackson 3.0, the first major version in eight years, is a hard break from the 2.x line. The Maven groupId and Java package shift from `com.fasterxml.jackson` to `tools.jackson`, while the annotation package stays put so Jackson 2 and 3 can coexist in the same project. The mutable `ObjectMapper` is replaced by an immutable `JsonMapper` built through a locked Builder pattern, and the entire exception hierarchy switches from checked to unchecked exceptions.

Default behaviors that will silently change API contracts include date serialization moving from timestamps to ISO-8601 strings, primitive null fields throwing exceptions instead of defaulting to zero, and month indexing flipping from 0-based to 1-based. Three previously separate Java 8 support modules are now baked into `jackson-databind`.

Spring Boot 4 ships with Jackson 3 as the default JSON library and manages both Jackson 2 and 3 dependencies to allow gradual migration. The first LTS release will be Jackson 3.1; the 3.0 GA is a transitional version that still demands a JDK 17 baseline.

Takeaways
Jackson 3 requires JDK 17 or later; projects on JDK 8 or 11 must upgrade the runtime first.
The Maven groupId changes from `com.fasterxml.jackson` to `tools.jackson`, and Java imports move to `tools.jackson` — except for annotations, which stay in the old package.
`ObjectMapper` is replaced by the immutable `JsonMapper`, built exclusively through a Builder pattern that locks configuration on `build()`.
Format-specific mappers (`JsonMapper`, `YAMLMapper`, `XmlMapper`) are now mandatory; constructing a generic `ObjectMapper` with a factory is prohibited.
The exception hierarchy switches from checked `JsonProcessingException` to unchecked `JacksonException`, removing mandatory try-catch blocks.
Date serialization defaults to ISO-8601 strings instead of timestamps, which can break frontends that expect numeric epoch values.
`FAIL_ON_NULL_FOR_PRIMITIVES` now defaults to `true`, so a null JSON value for a primitive field throws an exception instead of assigning a default.
Month handling defaults to 1-based indexing (January = 1) instead of the previous 0-based behavior.
Three Jackson 2.x modules — parameter-names, jdk8, and jsr310 — are integrated directly into `jackson-databind` and no longer need separate dependencies.
Jackson 3.0 is a transitional release; the first LTS version is Jackson 3.1, and production upgrades should target that.
Spring Boot 4 manages both Jackson 2 and 3 dependencies, allowing coexistence and gradual migration with the `spring.jackson.use-jackson2-defaults` flag.
OpenRewrite provides an automated migration recipe (`UpgradeJackson_2_3`) to handle package renames and API changes mechanically.
Conclusions

Keeping the annotation package under the old `com.fasterxml.jackson` namespace while moving core code to `tools.jackson` is a deliberate coexistence hack — it lets libraries compiled against Jackson 2 annotations still work at runtime alongside Jackson 3.

Making `ObjectMapper` immutable via a Builder is less about API fashion and more about eliminating a real class of production bugs where shared mappers were reconfigured mid-flight in multi-threaded services.

Switching from checked to unchecked exceptions aligns Jackson with the broader Java ecosystem trend (Spring, Lombok) but removes a compiler-enforced reminder to handle malformed JSON, pushing that responsibility onto runtime discipline.

The default date format change from timestamps to ISO-8601 strings is the kind of breaking change that won't fail any tests if your test fixtures were also generated by Jackson 2.x — it will only surface in integration with external clients.

Concepts & terms
JsonMapper (Jackson 3)
The immutable replacement for Jackson 2.x's `ObjectMapper`. Constructed via a Builder pattern, its configuration is locked after `build()` is called, making it safe to share across threads without synchronization.
Checked vs. Unchecked Exceptions in Java
Checked exceptions (subclassing `Exception`) must be caught or declared in a method signature; unchecked exceptions (subclassing `RuntimeException`) do not. Jackson 3 moved its entire exception tree from checked to unchecked, eliminating mandatory try-catch blocks.
ISO-8601 Date Format
An international standard for representing dates and times as strings (e.g., `2026-07-20T12:00:00Z`). Jackson 3 now defaults to this format instead of numeric epoch timestamps, which changes the shape of JSON payloads.
OpenRewrite
An automated refactoring tool for Java that applies predefined 'recipes' to source code. It ships a recipe specifically for migrating Jackson 2.x code to Jackson 3.x, handling package renames and API changes mechanically.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗