
# Stop Letting Jackson Accept Garbage: Strict JSON Parsing in Spring Boot
Most Spring Boot APIs think they are strict — until a client sends something slightly “off”, and your app quietly accepts it. Examples I’ve seen in real systems: "count": "10" (string) accepted where you expected an integer "amount": 1.2 accepted where you expected an integer cents value "age": "" becoming 0 or null depending on coercion rules unknown fields being ignored (and bugs staying hidden for months) If you care about contracts, lenient deserialization is technical debt . The earlier you fail, the cheaper it is. This post shows a practical way to make JSON parsing predictable and strict in Spring Boot, without turning your codebase into a pile of custom validators. What “strict” means (pick your rules) There’s no universal strictness. Define your contract. A reasonable default for backend APIs: Unknown fields fail (clients can’t silently send typos) Wrong types fail (string vs number, boolean vs string, etc.) No “magical” coercions ( "" → null , "10" → 10, 1.0 → 1, etc.) Number
Continue reading on Dev.to Webdev
Opens in a new tab



