Quick revision
The short answer
I would ship the shared configuration as a Spring Boot starter that contributes builder customizers and Module beans, never its own ObjectMapper bean, so Boot keeps building the mapper and every team keeps its properties and extensions. The starter defines naming, date format, null inclusion and unknown property behaviour once, registers shared modules for common types such as money and typed ids, and tests the JSON of those types itself. Teams extend it by adding their own Module beans or customizers, ordered to run after the platform's.
What to remember
In this answer, we designed a shared Jackson configuration as a Spring Boot starter that adds customizers and Module beans instead of defining an ObjectMapper, so Boot keeps building the mapper and its properties keep working. The starter fixes naming, dates, null inclusion and unknown properties once, runs before Boot's property customizer so teams can override with properties, and registers shared modules for money and typed ids. Teams extend it with their own Module beans and customizers, and ApplicationContextRunner tests in the starter lock in both the JSON of shared types and the extension promises.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would ship the shared configuration as a Spring Boot starter that contributes builder customizers and Module beans, never its own ObjectMapper bean, so Boot keeps building the mapper and every team keeps its properties and extensions. The starter defines naming, date format, null inclusion and unknown property behaviour once, registers shared modules for common types such as money and typed ids, and tests the JSON of those types itself. Teams extend it by adding their own Module beans or customizers, ordered to run after the platform's.
Why this question is asked
In a company with dozens of services, JSON drift is expensive. One service writes amounts as numbers and another as strings, one uses camelCase and another snake_case, and every client team writes adapters. A shared configuration fixes that, but if it is built the wrong way, typically by publishing a library with a ready-made ObjectMapper bean, it takes away Boot's configuration and forces teams to fork the library whenever they need one more setting. Interviewers ask this design question to see whether we can standardise without blocking teams. In this answer, we will decide what to standardise, build the starter around customizers, add shared modules, show how teams extend it, and test it. I will use Boot 3 names and note the Boot 4 equivalents.
1Why Customizers and Not an ObjectMapper Bean
Spring Boot builds its ObjectMapper from a builder and only creates it when no other ObjectMapper bean exists. A starter that defines its own ObjectMapper bean therefore switches Boot's configuration off for every service that uses it: the spring.jackson.* properties stop working, well-known modules may be missing, and any Module bean a team declares is ignored. Teams who need one extra setting then define their own mapper, and the shared configuration is gone.
Customizers avoid that. A Jackson2ObjectMapperBuilderCustomizer (in Boot 4, JsonMapperBuilderCustomizer) receives the same builder Boot uses and adds settings to it. Boot still creates the mapper, so everything else in Boot's design keeps working, and other customizers, including the teams' own, can add to the result.
- Team customizers and Module beansservice-specific types and settings, run last
- Platform startercustomizer with company defaults, shared modules
- Spring Boot
JacksonAutoConfiguration, properties, well-known modules - Jacksonthe builder and the mapper
4 layers, from the top down. Step through them one at a time.
Each layer adds to the builder; nobody replaces the mapper.
2Deciding the Company Defaults
The starter should standardise only what clients see and what causes drift: property naming, date and time format, null handling and unknown properties. A typical set is camelCase names, dates and times as ISO-8601 strings with an offset, java.time only, nulls omitted from responses (NON_NULL) and unknown properties ignored on read, so that adding a field never breaks an older consumer. These choices are written in the API guidelines with an example, and each one has a reason; for instance, omitting nulls keeps payloads smaller but means clients must treat a missing field and a null the same way.
Notice the order of -100. Boot's own customizer, the one that applies spring.jackson.* properties, has order 0. Running before it means a team can still override a company default with a property in its application.yml, and the property wins because it is applied later. Boot's standard customizer generally applies only the properties that are set, so the platform defaults survive where a team says nothing; it is worth a test to confirm this for each setting on your Boot version.
3Shared Modules for Common Types
The biggest source of drift is not settings but types. Money is the classic example: as a JSON number, 0.1 + 0.2 problems and lost scale appear in JavaScript clients, so the company writes amounts as strings with an explicit currency. Typed ids, small wrapper types such as OrderId around a long or UUID, should always be strings in JSON, because JavaScript loses precision on numbers above 2 to the power 53. Putting serializers for these types into one module in the starter makes every service write them identically, and fixing a bug in one place fixes it everywhere.
4How Teams Extend Without Replacing
A team that needs something extra uses the same mechanisms as the platform. For a new type, it declares a Module bean, and Boot registers it with the rest. For a setting, it declares its own customizer, which runs after the platform's because of its default order, or sets a spring.jackson property. A team should only need its own mapper for a genuinely different format, such as a legacy partner integration, and then it builds a second, qualified mapper from the builder or a copy of it rather than replacing the primary one.
5Testing the Starter
The starter owns the JSON contract for shared types, so it carries the tests. We use ApplicationContextRunner, Boot's helper for testing auto-configuration without starting a full application, to load the starter with Boot's Jackson configuration and assert on the mapper's output for each shared type and setting. We also test the extension points: a context with an extra Module bean still has the platform module, and a property override beats the platform default.
Notice the second test. It protects the promise we made to teams, that they can override defaults with properties, so a later change to the starter cannot silently break it. When the company moves to Boot 4 and Jackson 3, the starter switches to JsonMapperBuilderCustomizer and JacksonModule, and these same tests show whether the JSON of shared types changed.
6Follow-up questions
Why not just publish a JSON utility class with a static mapper?
Because Spring's message converters, clients and integrations use Boot's mapper, not ours. A static mapper gives a second configuration that drifts from the one the API actually uses. The starter configures the real mapper, so every path through the service writes the same JSON.
Should the starter fail on unknown properties to catch client mistakes?
For a company-wide default, ignoring them is usually better, because it lets producers add fields without breaking older consumers. Teams with strict input requirements can enable failing for their own service or validate specific requests, but the shared default should favour compatibility.
How do we roll out a change to a shared default?
As a versioned change to the starter, with release notes and golden-file test results, because it changes the JSON of every service that upgrades. Teams pick it up on their schedule, and a breaking change, such as a new date format, is announced like any API change.
7Conclusion
In this answer, we designed a shared Jackson configuration as a Spring Boot starter that adds customizers and Module beans instead of defining an ObjectMapper, so Boot keeps building the mapper and its properties keep working. The starter fixes naming, dates, null inclusion and unknown properties once, runs before Boot's property customizer so teams can override with properties, and registers shared modules for money and typed ids. Teams extend it with their own Module beans and customizers, and ApplicationContextRunner tests in the starter lock in both the JSON of shared types and the extension promises.
Open with
I'd build it as a Spring Boot starter that never defines an ObjectMapper bean, because Boot only creates its mapper if there isn't one, and a starter mapper would switch off the spring.jackson properties, the well-known modules and every team's Module beans.
Then, if they want more
Instead the starter contributes a builder customizer, Jackson2ObjectMapperBuilderCustomizer in Boot 3 and JsonMapperBuilderCustomizer in Boot 4, with the company defaults: naming strategy, ISO-8601 dates with offsets instead of timestamps, NON_NULL inclusion and ignoring unknown properties so producers can add fields safely.
I'd give it an order before Boot's standard customizer, so a team can still override a default with a property. The starter also registers a shared module for common types, like money as a string amount plus currency, and typed ids as strings so JavaScript clients don't lose precision.
Teams extend it the same way: their own Module beans get registered automatically, their own customizers run after the platform's, and for a truly different format they build a second qualified mapper rather than replacing the primary one.
And the starter carries tests: with ApplicationContextRunner I load it with Boot's Jackson auto-configuration and assert on the exact JSON for each shared type, plus tests that a team's module and a property override still work, so those promises can't silently break.
About this answer
- Last updated
- 12 November 2026
- 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.
- Official documentation
- Spring Framework reference, Spring Web MVC
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 "Design a shared Jackson configuration for all services and explain how teams can extend...": https://scrivio-interview-library.netlify.app/spring-boot/json-serialization/5b20af0fdc/