# Spring Boot 4.1: Jackson configuration before and after

Compare duplicate JSON keys and BigDecimal output by changing two properties in the same Spring Boot 4.1.0 application. `/orders` only echoes a quantity; it does not store or execute an order.

## Environment and scope

- This example uses **JDK 21**. Set `JAVA_HOME` and check that `java -version` selects JDK 21.
- The Gradle 9.5.1 wrapper is included. The first build needs internet access to download Gradle and Maven Central dependencies.
- Spring Boot 4.1.0 and dependency-management plugin 1.1.7; the verified build resolved Jackson 3.1.4.
- Verified on October 7, 2026, with macOS arm64 and Microsoft OpenJDK 21.0.9: six MockMvc tests and six real HTTP requests against separate JAR processes. Results are in `verification.json`.
- No version upgrade, throughput, CBOR/XML, gRPC, SSRF protection, or AOT testing. Windows and Linux execution has not been verified.

## 1. Extract and test

These commands use a macOS/Linux shell, starting in the directory containing the downloaded ZIP.

```sh
unzip spring-boot-41-jackson-v1.zip
cd spring-boot-41-jackson-v1
chmod +x gradlew
java -version
./gradlew clean test bootJar
```

All six tests should pass. Open `build/reports/tests/test/index.html` for details. The executable JAR is `build/libs/spring-boot-41-jackson-1.0.0.jar`. Check source file integrity with `shasum -a 256 -c SHA256SUMS` on macOS or `sha256sum -c SHA256SUMS` on Linux.

## 2. Send baseline requests

Start the application in the first terminal. It binds only to loopback at `127.0.0.1:18081`.

```sh
java -jar build/libs/spring-boot-41-jackson-1.0.0.jar --spring.profiles.active=baseline
```

In a second terminal, send these three requests:

```sh
curl -sS -w '\nHTTP %{http_code}\n' -H 'Content-Type: application/json' -d '{"quantity":1}' http://127.0.0.1:18081/orders
curl -sS -w '\nHTTP %{http_code}\n' -H 'Content-Type: application/json' -d '{"quantity":1,"quantity":99}' http://127.0.0.1:18081/orders
curl -sS -w '\nHTTP %{http_code}\n' http://127.0.0.1:18081/amount
```

In order, the responses are `{"quantity":1}` / HTTP 200, `{"quantity":99}` / HTTP 200, and `{"amount":1E+3}` / HTTP 200. The last duplicate value wins for the mutable DTO used in this example.

## 3. Enable the settings and repeat

Stop the application with Ctrl+C in the first terminal, then restart it:

```sh
java -jar build/libs/spring-boot-41-jackson-1.0.0.jar --spring.profiles.active=strict
```

`src/main/resources/application-strict.properties` contains:

```properties
spring.jackson.read.strict-duplicate-detection=true
spring.jackson.write.write-bigdecimal-as-plain=true
```

Repeat the same three curl commands in the second terminal.

| Request | baseline | strict |
| --- | --- | --- |
| Quantity 1 | 200 / `{"quantity":1}` | 200 / `{"quantity":1}` |
| Repeated quantity key | 200 / `{"quantity":99}` | 400 / Bad Request |
| BigDecimal("1E+3") | 200 / `{"amount":1E+3}` | 200 / `{"amount":1000}` |

The HTTP 400 error timestamp varies between requests. MockMvc checks the status; the real HTTP record retains only status/error/path from that error response. Number-format tests compare raw response strings, because numeric comparison would hide the representation change.

## Adoption and troubleshooting

- `read.*`/`write.*` configure common stream features; do not confuse them with JSON-specific `json.read.*`/`json.write.*`. This application uses Boot's auto-configured Jackson mapper.
- Applications with a custom mapper or HTTP message converter should test real API requests rather than assume these results apply unchanged.
- Rejecting duplicate keys can turn existing clients' requests into HTTP 400 responses. It does not validate positive or required quantities. Parsing overhead was not benchmarked here.
- `1000` remains a JSON number. This does not convert it to a string, enforce decimal places, or guarantee large-number precision in a browser.
- If strict behaves like baseline, check the active profile in the startup log and the configuration path. For a port conflict, stop the previous example process or use `--server.port=18082` and update the curl URLs.
- For JDK errors, check Java 21's `JAVA_HOME`/PATH. For download failures, check access to Gradle distribution servers and Maven Central.

## Files and references

`src/main/` contains the complete application and configuration; `src/test/` contains tests for both profiles. No database, API token, or production service is required. `verification.json` records an actual pre-publication run; use your local test report and curl responses to assess a new run. Build output, caches, and secrets are excluded from the ZIP.

- [Spring Boot 4.1 release notes](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.1-Release-Notes)
- [Jackson 3.1.4 StreamReadFeature](https://github.com/FasterXML/jackson-core/blob/jackson-core-3.1.4/src/main/java/tools/jackson/core/StreamReadFeature.java)
- [Jackson 3.1.4 StreamWriteFeature](https://github.com/FasterXML/jackson-core/blob/jackson-core-3.1.4/src/main/java/tools/jackson/core/StreamWriteFeature.java)

The Gradle 9.5.1 wrapper comes from the existing project. Its scripts retain their Apache License 2.0 notices.
