Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

Your Spring Boot 3 service has custom serializers, mix-ins and a Jackson2ObjectMapperBuilderCustomizer. Plan the upgrade to Spring Boot 4 with Jackson 3.

I would treat it as a planned migration with a safety net. Spring Boot 4 auto-configures a Jackson 3 JsonMapper, so our Jackson2ObjectMapperBuilderCustomizer must move to the new customizer for the JsonMapper builder (check the exact name for your version), and Jackson 2 support remains only as a deprecated option. Custom serializers and mix-ins get new imports and some new signatures, such as SerializationContext instead of SerializerProvider, which OpenRewrite recipes help with. Before touching anything we record golden JSON for key endpoints and events, we check third-party libraries that bring Jackson 2 modules, and we roll out service by service while watching consumer errors.

Why this question is asked

A Spring Boot 4 upgrade is mostly routine, but the Jackson part is where it can hurt other teams: a serializer that compiles fine may still write a date or an amount differently, and consumers find out in production. Interviewers ask for a plan because the order of steps matters more than any single code change. In this answer, we will first record the current behaviour, then map what changes in Boot 4, port the customizer, the serializers and the mix-ins, deal with third-party libraries, and finally roll out safely.

1Record the Current JSON Before Changing Anything

The most important step happens on the old version. We write tests that serialize representative objects with the application's real mapper, the one Spring Boot builds with all our customizations, and save the output as golden files. We cover every public endpoint's main responses, every event we publish, and the special cases our custom serializers exist for: money, dates, enums, nulls, polymorphic types. We also save a few incoming examples and check that they still deserialize to the same objects.

Java
@SpringBootTest
class JsonGoldenTest {
@Autowired ObjectMapper mapper; // the auto-configured one, with our customizer
@Test
void orderResponse() throws Exception {
String json = mapper.writeValueAsString(Fixtures.order());
JSONAssert.assertEquals(read("golden/order.json"), json, JSONCompareMode.STRICT);
}
}
// On Spring Boot 3: generate the golden files once, review them, commit them

After the upgrade the same tests run against the Jackson 3 mapper. Notice that the test injects the mapper rather than creating one: a new mapper would miss the configuration we are trying to protect.

2What Changes in Spring Boot 4

Spring Boot 4 auto-configures a Jackson 3 JsonMapper, in the tools.jackson packages, and its HTTP message converters use it. Customizing that mapper happens through a new customizer type that receives the JsonMapper builder, replacing Jackson2ObjectMapperBuilderCustomizer. Spring Boot 4 keeps Jackson 2 support only as a deprecated option for applications that cannot move yet, and the related Boot annotations for registering serializers have new names as well. Exact class and property names are worth checking in the Spring Boot 4 migration guide for your version rather than trusting memory.

Jackson pieces and their Spring Boot 4 counterparts
What we have on Boot 3Where it goes on Boot 4Note
Jackson2ObjectMapperBuilderCustomizerCustomizer of the JsonMapper builderCheck the exact type name
Custom JsonSerializer subclassesValueSerializer, new packagesSerializationContext parameter
Custom JsonDeserializer subclassesValueDeserializer, new packagesUnchecked exceptions
Mix-in classesUsually unchanged annotationsRegistration through the builder
JavaTimeModule registrationRemovejava.time is built in
Injected ObjectMapper (Jackson 2)Injected JsonMapper (Jackson 3)Different package
The annotations mostly stay; the code that configures and extends Jackson moves.

3Porting the Customizer, Serializers and Mix-Ins

The customizer usually becomes shorter. Feature toggles and module registration move from the old builder to the JsonMapper builder. Anything that mutated the mapper after building has to become builder configuration, because Jackson 3 mappers are immutable.

Java
// Spring Boot 3, Jackson 2
@Bean
Jackson2ObjectMapperBuilderCustomizer json() {
return b -> b.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.mixIn(Order.class, OrderMixIn.class)
.serializerByType(Money.class, new MoneySerializer());
}
// Spring Boot 4, Jackson 3 (customizer type name: check your version)
@Bean
JsonMapperBuilderCustomizer json() {
return b -> b.disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS) // feature moved: check name
.addMixIn(Order.class, OrderMixIn.class)
.addModule(new SimpleModule().addSerializer(Money.class, new MoneySerializer()));
}
// Custom serializer, Jackson 3
class MoneySerializer extends StdSerializer<Money> {
MoneySerializer() { super(Money.class); }
@Override
public void serialize(Money m, JsonGenerator g, SerializationContext ctxt) { // no throws IOException
g.writeStartObject();
g.writeStringProperty("amount", m.amount().toPlainString()); // {"amount":"12.50",
g.writeStringProperty("currency", m.currency()); // "currency":"EUR"}
g.writeEndObject();
}
}

Mechanical changes such as imports, base class names and SerializerProvider to SerializationContext are best done with OpenRewrite, which has recipes for the Jackson 3 migration, followed by a manual review. Generator and parser method names were also tidied in Jackson 3, for example around field names and strings, so compile errors in serializers are expected and each one should be checked against the golden tests. Mix-ins usually need nothing more than new registration, because their annotations come from jackson-annotations, which keeps its package.

4Checking Third-Party Libraries

Next we look at the dependency tree for Jackson 2 artifacts that remain after the upgrade. Libraries such as SDKs, OpenAPI tools or messaging clients may bring their own Jackson 2 modules or create their own Jackson 2 mappers. Because the packages differ, Jackson 2 and Jackson 3 can live together without class conflicts. But there is a catch: they do not share configuration. A library serializing our Money with its own Jackson 2 mapper will ignore the serializer we just ported, and its output may change or differ from ours. For each such library we either upgrade it to a Jackson 3 version, give it a configured Jackson 2 mapper on purpose, or accept and test its output.

5Rolling Out Service by Service

With the golden tests green, or every difference reviewed and accepted, we deploy one service at a time, starting with a low-risk internal one. During each rollout we watch consumer error rates and dead-letter queues for the events that service publishes, as well as 400 responses on its own endpoints, which reveal input that the new deserialization rejects. A canary release, a small share of traffic on the new version first, keeps any surprise small, and rolling back is just redeploying the previous version because nothing persistent changed.

Step throughUpgrade plan for one service
  1. Record golden JSON on Boot 3Responses, events, incoming samples
  2. Upgrade Boot and run OpenRewriteImports, base classes, signatures
  3. Port customizer, serializers, mix-insBuilder-based configuration
  4. Golden tests pass?
    YesCheck third-party Jackson 2 usersNoFix config or accept and announce
  5. Canary deployWatch consumer errors and 400s
  6. Full rollout, next service

6 steps in order. Play them, or step through them one at a time.

The golden tests turn silent output changes into visible test failures.

6Follow-up questions

Should we use the deprecated Jackson 2 support in Boot 4 to upgrade faster?

Only as a short bridge for a service blocked by a library that has no Jackson 3 version. It lets us take the rest of Spring Boot 4 now, but it postpones the real work and will go away in a later release, so I would track each such service with an end date.

What if the golden tests show that dates changed format?

Then I decide deliberately. If consumers depend on the old format, I configure the Jackson 3 builder to keep it and note that in the customizer. If the new format is the one we want anyway, I announce the change to consumers, ideally as part of a new API or event version, rather than letting it slip out with a framework upgrade.

How do you test the deserialization side?

With saved incoming examples, including old event versions still present in topics and requests from real clients with odd but valid shapes. Each one is deserialized and compared with the expected object, so stricter defaults in Jackson 3 show up as failing tests rather than rejected messages.

7Conclusion

In this answer, we planned the move to Spring Boot 4 and Jackson 3 starting with golden JSON recorded on the old version. We moved the Jackson2ObjectMapperBuilderCustomizer to the new JsonMapper builder customizer, ported serializers to the new packages and signatures with OpenRewrite's help, re-registered mix-ins, checked third-party libraries that keep their own Jackson 2 configuration, and rolled out service by service while watching consumer errors.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start before upgrading anything: on Spring Boot 3 I write golden tests that serialize key responses and events with the injected, fully customized mapper, plus deserialization tests for saved incoming payloads, and commit that output.

Then, if they want more

Then I upgrade. Spring Boot 4 auto-configures a Jackson 3 JsonMapper in the tools.jackson packages, and Jackson 2 support is only a deprecated option, so the Jackson2ObjectMapperBuilderCustomizer becomes a customizer of the JsonMapper builder; I would check the exact type and feature names in the migration guide.

Custom serializers move to the new packages and base classes, with SerializationContext instead of SerializerProvider and no checked IOException, and I let OpenRewrite do the mechanical part before reviewing by hand. Mix-ins mostly keep their annotations and only need registering on the builder. Then I check the dependency tree for libraries that still use Jackson 2.

Both versions can coexist because the packages differ, but they do not share configuration, so such a library ignores my serializers. Once golden tests pass or every difference is a deliberate, announced decision, I roll out service by service with a canary, watching consumer errors, dead-letter queues and 400 rates.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 4, Spring Boot 3
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your Spring Boot 3 service has custom serializers, mix-ins and a...": https://scrivio-interview-library.netlify.app/spring-boot/json-serialization/d47313dee5/