Scenario
A payload parses cleanly, yet the API rejects it with 422 Unprocessable Entity. This is the gap between syntax and contract: {"active": "true"} is perfectly valid JSON and still wrong if the schema demands a boolean. String-typed booleans are among the most common contract bugs because form inputs, environment variables, and query strings all deliver "true" as text. Check the payload against a schema before anyone starts "fixing" backend code that was never broken.
Broken input
schema: required name:string, active:boolean
payload: {"name":"Ada","active":"true"}
Goal
Use JSON Schema Validator / Generator to test the payload against the expected types and surface the exact field and mismatch, instead of inferring it from a vague 422.
Tool sequence
- Open JSON Schema Validator / Generator.
- Enter the schema — write it out, or generate a starter schema from a known-good payload and tighten the types.
- Paste the failing payload and run validation.
- Read the error:
activeexpects typebooleanbut gotstring. The quotes aroundtrueare the whole bug. - Fix the producer to send
"active": true(no quotes) and re-validate; if the payload came from a curl example, convert and inspect it with cURL to fetch / Axios to see where the value gets stringified.
Checkpoint output
✖ /active — expected boolean, received string
fixed payload:
{"name":"Ada","active":true}
Validation pins the failure to active being the string "true" instead of the boolean true — a one-character-class fix, found without touching backend code.
Common mistakes
- Stopping at JSON syntax validation when the contract is the real gate — parse success proves nothing about types.
- Letting generated schemas mark every field optional, so validation passes on payloads missing required data.
- Changing API code before confirming which side of the contract drifted.
- Testing only the happy-path payload; the schema earns its keep on edge cases like
null,"", and0.
Related tools and lessons
- JSON Validator - Validate & pretty-print JSON.
- JSON Formatter - Format, minify, and filter JSON by keys.
- JSON to TypeScript Interface Generator - Generate TypeScript interfaces from JSON samples.
- Related lesson: Find the JSON Syntax Error Breaking a Request
- Related lesson: Make a Nested JSON Response Readable