Quick revision
The short answer
I would make the consistent choice the easy one: a shared Spring Boot starter that configures Jackson the same way everywhere (property naming, date format, null handling, unknown fields), plus shared types for money, ids and timestamps whose JSON form is defined once. Contract tests catch any change in JSON output, written rules forbid risky features such as default typing and fix how polymorphism is done, and the move to Jackson 3 is planned centrally rather than by each team.
What to remember
In this answer, we saw that JSON shapes drift mostly through defaults, and we built a standard in layers: a shared starter that configures naming, dates, nulls and unknown fields; shared types with one JSON form for money, ids and timestamps; golden-file contract tests; written rules on polymorphism and forbidden default typing; and a central plan to carry the same forms onto Jackson 3.
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 make the consistent choice the easy one: a shared Spring Boot starter that configures Jackson the same way everywhere (property naming, date format, null handling, unknown fields), plus shared types for money, ids and timestamps whose JSON form is defined once. Contract tests catch any change in JSON output, written rules forbid risky features such as default typing and fix how polymorphism is done, and the move to Jackson 3 is planned centrally rather than by each team.
Why this question is asked
In a company with dozens of services, the same concept often appears in many JSON shapes: an amount as 12.5 in one API, "12.50" in another and 1250 cents in a third; a timestamp as epoch milliseconds here and ISO text there. Each difference is small, but together they create bugs at every integration and make client code full of special cases. Interviewers ask this leadership question to see whether we can turn a technical preference into a standard that teams actually follow. In this answer, we will see why shapes drift, then build the standard in layers: a shared configuration, shared types, contract tests, written rules, and central planning for Jackson 3.
1Why the Same Type Looks Different Everywhere
Drift rarely comes from disagreement. It comes from defaults. Jackson writes java.util.Date and Instant as numbers unless WRITE_DATES_AS_TIMESTAMPS is disabled, while Spring Boot disables it for us; a service that creates its own ObjectMapper with new ObjectMapper() silently gets different output. One team adds snake_case naming for a partner, another keeps camelCase. One writes nulls, another excludes them with NON_NULL. A BigDecimal becomes a JSON number, which JavaScript clients read as a double, while another team writes amounts as strings to keep precision.
So a standard has two jobs: decide each of these questions once, and make the decided answer the default that new services get without any effort.
2A Shared Jackson Configuration Through a Starter
The base layer is an internal Spring Boot starter, a small library with auto-configuration that every service already depends on. It customizes the mapper that Spring Boot builds, so teams do not have to remember any setting. It fixes the naming strategy, writes dates as ISO-8601 text, decides whether nulls are written, sets the unknown-field policy for requests and events, and registers the company's modules.
Notice that the starter customizes Spring Boot's mapper rather than declaring its own ObjectMapper bean. Declaring a bean would replace Boot's auto-configuration and its other customizers, which surprises teams. We also add a build check or an ArchUnit rule that flags new ObjectMapper() in production code, because a private mapper bypasses the standard.
3Shared Types With Defined JSON Forms
Configuration cannot decide what an amount looks like; types do. The starter's companion library offers a small set of value types such as Money, CustomerId and a Timestamp convention, each with exactly one JSON form and a serializer and deserializer in the CompanyTypesModule.
| Type | JSON form | Example |
|---|---|---|
| Money | Object with string amount and ISO currency | {"amount":"12.50","currency":"EUR"} |
| Identifiers | String, even when numeric inside | "ord_8f3a91" or "9007199254740993" |
| Instant in time | ISO-8601 in UTC with Z | "2026-01-01T00:00:00Z" |
| Calendar date | ISO-8601 date | "2026-01-01" |
| Enums | Upper snake case strings | "PAYMENT_PENDING" |
| Absent value | Field omitted, not null | no "discount" key |
The reasons for each choice are worth writing next to the table in the standard. Amounts are strings because a JSON number passes through doubles in many clients and loses cents or trailing zeros. Ids are strings because JavaScript numbers are exact only up to 2 to the power 53, so a 64-bit id can be silently corrupted. Timestamps are UTC instants because local times without a zone cannot be compared.
4Contract Tests That Detect Changes in Output
A standard that is not tested drifts again within a year. Each service keeps golden files, saved JSON examples of its main responses and events, and a test serializes known objects and compares the result with them. The comparison should ignore key order but be strict about names, types and extra fields. When a Jackson or Spring Boot upgrade changes a default, the test fails in the pull request instead of in a consumer's production logs.
The starter's own test suite runs the same kind of check for every shared type, so the central team learns first when an upgrade changes anything. For APIs between teams, consumer-driven contract tools such as Pact or Spring Cloud Contract add the consumer's point of view.
5Rules on Polymorphism and Forbidden Features
Some decisions are rules rather than configuration. Polymorphic JSON uses @JsonTypeInfo with Id.NAME and a property called type, with subtypes listed explicitly; class names never appear in payloads. Default typing is forbidden, and the build fails if activateDefaultTyping appears. Entities are never serialized directly. Custom serializers live in the shared module when they concern shared types, so two teams do not write two Money serializers.
We keep the written standard short, two or three pages with examples, and we explain the reason behind each rule. People follow rules they understand and quietly ignore rules that look arbitrary.
6Planning the Jackson 3 Move Centrally
Jackson 3 changes packages, makes mappers immutable and changes some defaults, and Spring Boot 4 moves to it. If each of 80 services migrates on its own, we will get 80 slightly different results. Instead, the central team publishes a starter version for Spring Boot 4 that reproduces today's JSON forms on Jackson 3, proves it with the same golden tests, and documents any intended changes. Services then upgrade by bumping one dependency, and their own golden files confirm that nothing visible changed. We track adoption per service and set a date after which the Jackson 2 starter is no longer maintained.
- Write the standardShort, with reasons and examples
- Ship the starter and types moduleDefaults are the standard
- Add golden tests in each serviceShape changes fail the build
- Enforce rules in the buildNo default typing, no private mappers
- Plan Jackson 3 in the starterSame JSON on the new major version
5 steps in order. Play them, or step through them one at a time.
Each step makes the standard harder to break by accident.
7Follow-up questions
How do you get existing services with different shapes to adopt the standard?
Not by breaking their clients. New services and new API versions follow the standard from the start. Existing endpoints keep their shape, and the starter allows a documented per-service override for legacy forms. When a team publishes a new version of an API anyway, it moves to the standard forms, and we track the remaining exceptions on a list that shrinks over time.
Should the standard choose snake_case or camelCase?
Either works; consistency is what matters. I would pick the form most existing public APIs already use, because changing names is the most visible break for clients, and allow a per-API override only for partners whose contracts demand another form.
Who owns the starter?
A platform or architecture team with a clear maintainer, a changelog and semantic versioning. Changes to JSON forms go through a short review with representatives of consuming teams, because a change in the starter changes the output of every service at the next upgrade.
8Conclusion
In this answer, we saw that JSON shapes drift mostly through defaults, and we built a standard in layers: a shared starter that configures naming, dates, nulls and unknown fields; shared types with one JSON form for money, ids and timestamps; golden-file contract tests; written rules on polymorphism and forbidden default typing; and a central plan to carry the same forms onto Jackson 3.
Open with
I would make the standard the default rather than a document people have to remember. First, an internal Spring Boot starter that customizes Boot's own mapper, not a replacement bean, with the decided naming strategy, ISO dates instead of timestamps, a null inclusion rule and the unknown-field policy.
Then, if they want more
Second, shared value types for the things that cause most integration bugs: Money as a string amount plus currency, ids as strings because JavaScript loses precision above 2 to the 53, and instants as ISO-8601 UTC. A module in the starter gives each one exactly one JSON form.
Third, golden-file tests in every service and in the starter itself, comparing serialized output strictly, so a default change from an upgrade fails the build instead of a consumer. Fourth, a few rules enforced in the build: polymorphism with type names and an explicit subtype list, no default typing, no new ObjectMapper in production code, no entities in responses.
And finally, I would plan the Jackson 3 and Spring Boot 4 move centrally: one starter release that reproduces today's JSON on Jackson 3, proven by the same golden tests, so each service upgrades by changing one version.
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.
- 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 "How would you set standards for JSON serialization across your services, so that the...": https://scrivio-interview-library.netlify.app/spring-boot/json-serialization/957af22895/