Spring Boot 4.1 Jackson Settings: Comparing Duplicate JSON Keys and BigDecimal Output
Which value does an API receive when the same JSON field appears twice?
{"quantity":1,"quantity":99}What must change to make an API output 1000 instead of 1E+3?
I applied Spring Boot 4.1 Jackson settings to a small HTTP API to compare these behaviors. I ran the same app with a baseline profile that adds neither setting and a strict profile that enables both, sending identical requests to each.
The observed results were:
| Check | baseline | strict |
|---|---|---|
| Normal quantity input | HTTP 200, quantity 1 returned | HTTP 200, quantity 1 returned |
| Duplicate quantity key | HTTP 200, quantity 99 returned | HTTP 400 |
| BigDecimal output | {"amount":1E+3} | {"amount":1000} |
Execution record: 2026-10-07
Six MockMvc tests and six HTTP requests to a separate JAR process were checked with Spring Boot 4.1.0 and Jackson 3.1.4.
This compares the same app version before and after applying settings. It is not a comparison with an earlier Spring Boot version or the result of upgrading an existing production service.
1. What this exercise checks
Spring Boot 4.1 can auto-configure Jackson reading and writing features shared across formats through spring.jackson.read.* and spring.jackson.write.*. This exercise applies two of those settings to JSON requests and responses. Spring Boot 4.1 release notes
I narrowed the checks to three questions:
- Does a normal request still work with either configuration?
- Can a setting reject a request containing duplicate field names?
- Can BigDecimal output change from scientific to plain notation?
The execution environment was:
| Item | Recorded environment |
|---|---|
| Operating system | macOS arm64 |
| JDK | Microsoft OpenJDK 21.0.9 |
| Spring Boot | 4.1.0 |
| Jackson | 3.1.4 |
| Gradle Wrapper | 9.5.1 |
| Automated tests | Three baseline and three strict tests |
| Actual HTTP checks | Three per profile, six total |
This example uses no database or API token. Although it has an /orders endpoint, it only echoes the received quantity. It does not save or execute real orders.
2. Complete source and verification materials
The code and recorded results are available here:
- Complete source and tests ZIP
- English execution guide
- Korean execution guide
- Execution record JSON
- ZIP SHA-256
The ZIP contains the Gradle Wrapper, build configuration, app source, profile settings, and tests.
verification.json is a stored record of the 2026-10-07 execution. A passing status in that file does not establish that a new execution succeeded. Check a new run through its local test report and HTTP responses.
3. Code and settings used in the comparison
The controller has two endpoints:
POST /orders: deserialize JSON into a DTO and return it unchanged.GET /amount: returnBigDecimal("1E+3").
package example;import java.math.BigDecimal;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class DemoController { @PostMapping("/orders") public Order echo(@RequestBody Order order) { return order; } @GetMapping("/amount") public Amount amount() { return new Amount(new BigDecimal("1E+3")); } public static class Order { private int quantity; public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } } public record Amount(BigDecimal amount) {}}Order is a mutable DTO with a setter. With this example's baseline settings, reading duplicate quantity fields left the last value, 99.
That observation should not be generalized to every DTO and Jackson configuration.
Shared settings
src/main/resources/application.properties contains:
spring.application.name=spring-boot-41-jacksonserver.address=127.0.0.1server.port=18081The example listens on 127.0.0.1:18081 on the local computer.
Settings added in the strict profile
src/main/resources/application-strict.properties contains two lines:
spring.jackson.read.strict-duplicate-detection=truespring.jackson.write.write-bigdecimal-as-plain=trueThe first enables detection of duplicate field names while reading a JSON object. It corresponds to Jackson's STRICT_DUPLICATE_DETECTION. Jackson 3.1.4 reading features
The second writes BigDecimal values in plain rather than scientific notation. It corresponds to WRITE_BIGDECIMAL_AS_PLAIN. Jackson 3.1.4 writing features
These properties use the shared stream-feature paths spring.jackson.read.* and spring.jackson.write.*. Do not replace them with the JSON-specific paths spring.jackson.json.read.* and spring.jackson.json.write.*.
The baseline profile adds neither setting. Both profiles use the same controller and Boot's auto-configured Jackson mapper.
4. Check the build and tests first
The commands below use macOS/Linux shell syntax. The recorded execution was on macOS; this does not claim verification on other operating systems.
Prepare JDK 21 and make sure JAVA_HOME and java -version point to it. The initial build needs internet access to download Gradle and dependencies.
Start in the directory containing the downloaded ZIP.
unzip spring-boot-41-jackson-v1.zipcd spring-boot-41-jackson-v1chmod +x gradlewjava -version./gradlew clean test bootJarConfirm that the build and tests succeed before moving to the next step.
The relevant files are:
Test reportbuild/reports/tests/test/index.htmlExecutable JARbuild/libs/spring-boot-41-jackson-1.0.0.jarAll six tests passed in the recorded run, with no failures, errors, or skipped tests.
The automated tests check normal input, duplicate-key input, and BigDecimal output in each profile.
5. Send identical requests to baseline and strict
Start baseline
Run the app in the first terminal:
java -jar build/libs/spring-boot-41-jackson-1.0.0.jar \ --spring.profiles.active=baselineConfirm that the app has started and leave that terminal running.
In a second terminal, send these requests in order.
Normal quantity input
curl -sS -w '\nHTTP %{http_code}\n' \ -H 'Content-Type: application/json' \ -d '{"quantity":1}' \ http://127.0.0.1:18081/ordersDuplicate quantity key
curl -sS -w '\nHTTP %{http_code}\n' \ -H 'Content-Type: application/json' \ -d '{"quantity":1,"quantity":99}' \ http://127.0.0.1:18081/ordersBigDecimal output
curl -sS -w '\nHTTP %{http_code}\n' \ http://127.0.0.1:18081/amountThe recorded responses, in order, were:
{"quantity":1}HTTP 200{"quantity":99}HTTP 200{"amount":1E+3}HTTP 200Restart with strict
Stop the baseline app with Ctrl+C in the first terminal.
Run the same JAR with the strict profile:
java -jar build/libs/spring-boot-41-jackson-1.0.0.jar \ --spring.profiles.active=strictRun the same three curl commands again in the second terminal.
The recorded comparison is:
| Request | baseline | strict |
|---|---|---|
POST /orders — {"quantity":1} | 200 / {"quantity":1} | 200 / {"quantity":1} |
POST /orders — {"quantity":1,"quantity":99} | 200 / {"quantity":99} | 400 / Bad Request |
GET /amount | 200 / {"amount":1E+3} | 200 / {"amount":1000} |
The duplicate-key 400 response includes a timestamp that varies between runs. The public verification record omits that value and retains these fields:
{ "status": 400, "error": "Bad Request", "path": "/orders"}This is not a copy of every field in the actual response; it shows the fields preserved in the verification record.
6. What differences the tests examine
The example has two forms of verification:
| Method | What it checks |
|---|---|
| Six MockMvc tests | Profile-specific request handling and responses within the Spring application configuration |
| Six HTTP requests to a separate JAR process | Status and body from actual requests to the running app's local port |
MockMvc tests and HTTP checks against a separate process are counted separately.
For BigDecimal in particular, value and representation must be distinguished.
{"amount":1E+3}{"amount":1000}These responses have the same numeric value, but this exercise checks the difference in output strings. Parsing and comparing them numerically can hide that difference.
The tests therefore compare raw response strings. The strict test contains:
@Testvoid bigDecimalRepresentation() throws Exception { mvc.perform(get("/amount")) .andExpect(status().isOk()) .andExpect(content().string("{\"amount\":1000}"));}The baseline test expects this string for the same request:
.andExpect(content().string("{\"amount\":1E+3}"));The strict duplicate-key test checks for HTTP 400. It does not assert an identical complete error response or a fixed timestamp.
7. Decisions before applying this to your own API
Rejecting duplicate keys changes the input contract
In this example, the duplicate-key request changes from a 200 response to a 400 response.
Check what existing clients send and decide whether duplicate fields should be treated as errors. Also verify that normal requests still succeed.
This setting does not validate positive quantities or required input fields. Duplicate-name detection and validation of values are separate requirements.
This exercise did not measure the performance impact of duplicate detection.
The BigDecimal setting changes output notation
Changing 1E+3 to 1000 still produces a JSON number.
Do not interpret this setting as:
- Converting numbers into JSON strings.
- Fixing the number of decimal places.
- Guaranteeing precision when a browser reads large numbers.
The verified scope here is the change in output notation for BigDecimal("1E+3").
Check the mapper configuration in the actual app
This example uses Boot's auto-configured Jackson mapper.
If an app supplies its own mapper or HTTP message converter, do not assume that adding the same properties has the same effect. Send requests to the actual endpoint and check the result.
If strict behaves like baseline, examine these points:
- Check that the startup log lists
strictas an active profile. - Check that the settings are in
application-strict.properties. - Make sure requests are not reaching a baseline process you left running.
- Check whether a custom mapper or converter handles the requests and responses.
If the port is occupied, stop the existing example process or add --server.port=18082 to the startup command. Change the curl URL to match the new port.
8. Other Spring Boot 4.1 changes as documentation references
The Spring Boot 4.1 release notes describe changes beyond Jackson. The following are documented features, not execution results from this example. Spring Boot 4.1 release notes
| Item | Documented change | Executed in this exercise? |
|---|---|---|
| gRPC | Support for writing and testing server and client applications | No |
| HTTP address filtering | Configure reactive and blocking HTTP clients with InetAddressFilter to block outgoing requests to specified addresses | No |
| Maven test AOT | Test AOT processing is skipped through maven.test.skip; do not assume -DskipTests alone also skips it | No |
HTTP address filtering is presented as SSRF mitigation. This article did not test blocking policies or bypasses and does not present evidence of production protection.
The executed scope is the effect of two Jackson settings on JSON requests and responses in the same Spring Boot 4.1.0 app. CBOR/XML, performance, other operating systems, and a full upgrade of an existing service were not verified.
To extend the example, first decide what inputs your API accepts and what numeric representation it requires, then add requests and tests for that contract.
Report an error or share feedback
Open a draft with this article’s title and URL. Review the message and recipient before sending.
Open email draftIf no email app opens, copy these details into your usual email service.
Related posts
Backend & Infrastructure Three Production Problems Local Tests Missed
Flyway never ran, npm failed inside Docker, and cache writes failed on permissions. Local tests missed each problem.
Backend & Infrastructure The App Started Without Its Category Column: Moving from ddl-auto=update to Flyway
A category change left the app running without a required column. I rebuilt the early database, then moved schema changes to Flyway.