Forge Fate
Backend & Infrastructure

Spring Boot 4.1 Jackson Settings: Comparing Duplicate JSON Keys and BigDecimal Output

6 min read

Which value does an API receive when the same JSON field appears twice?

json
{"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:

Checkbaselinestrict
Normal quantity inputHTTP 200, quantity 1 returnedHTTP 200, quantity 1 returned
Duplicate quantity keyHTTP 200, quantity 99 returnedHTTP 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:

  1. Does a normal request still work with either configuration?
  2. Can a setting reject a request containing duplicate field names?
  3. Can BigDecimal output change from scientific to plain notation?

The execution environment was:

ItemRecorded environment
Operating systemmacOS arm64
JDKMicrosoft OpenJDK 21.0.9
Spring Boot4.1.0
Jackson3.1.4
Gradle Wrapper9.5.1
Automated testsThree baseline and three strict tests
Actual HTTP checksThree 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:

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: return BigDecimal("1E+3").
java
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:

properties
spring.application.name=spring-boot-41-jacksonserver.address=127.0.0.1server.port=18081

The 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:

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

The 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.

sh
unzip spring-boot-41-jackson-v1.zipcd spring-boot-41-jackson-v1chmod +x gradlewjava -version./gradlew clean test bootJar

Confirm that the build and tests succeed before moving to the next step.

The relevant files are:

text
Test reportbuild/reports/tests/test/index.htmlExecutable JARbuild/libs/spring-boot-41-jackson-1.0.0.jar

All 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:

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

Confirm that the app has started and leave that terminal running.

In a second terminal, send these requests in order.

Normal quantity input

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

Duplicate quantity key

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

BigDecimal output

sh
curl -sS -w '\nHTTP %{http_code}\n' \  http://127.0.0.1:18081/amount

The recorded responses, in order, were:

text
{"quantity":1}HTTP 200
text
{"quantity":99}HTTP 200
text
{"amount":1E+3}HTTP 200

Restart with strict

Stop the baseline app with Ctrl+C in the first terminal.

Run the same JAR with the strict profile:

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

Run the same three curl commands again in the second terminal.

The recorded comparison is:

Requestbaselinestrict
POST /orders — {"quantity":1}200 / {"quantity":1}200 / {"quantity":1}
POST /orders — {"quantity":1,"quantity":99}200 / {"quantity":99}400 / Bad Request
GET /amount200 / {"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:

json
{  "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:

MethodWhat it checks
Six MockMvc testsProfile-specific request handling and responses within the Spring application configuration
Six HTTP requests to a separate JAR processStatus 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.

json
{"amount":1E+3}
json
{"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:

java
@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:

java
.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:

  1. Check that the startup log lists strict as an active profile.
  2. Check that the settings are in application-strict.properties.
  3. Make sure requests are not reaching a baseline process you left running.
  4. 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

ItemDocumented changeExecuted in this exercise?
gRPCSupport for writing and testing server and client applicationsNo
HTTP address filteringConfigure reactive and blocking HTTP clients with InetAddressFilter to block outgoing requests to specified addressesNo
Maven test AOTTest AOT processing is skipped through maven.test.skip; do not assume -DskipTests alone also skips itNo

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.

To: [email protected]

Open email draft

If no email app opens, copy these details into your usual email service.

Contact information