JSON Response Contract Assertions
Check expected equality, type and presence at explicit JSON Pointers.
Processing stays in your browser. Offline assertions for one supplied response. Equality compares JSON values and ignores object key order. No test code or network request is executed.
How to use the json response contract assertions
Start with the supplied example or replace json response, json assertion list. Choose Run tool and compare the result with the worked example before copying or downloading it.
How the tool works
Resolve each pointer against own keys and array positions, following JSON Pointer escaping. Evaluate equality, type, exists or absent and export a results table.
Worked example
View the example inputs
- JSON response
- { "items": [ { "id": 7 } ], "active": true }
- JSON assertion list
- [{"path":"/items/0/id","test":"equals","value":7},{"path":"/active","test":"type","value":"boolean"}]
The sample confirms that the first item's ID is seven and active is a boolean.
Good to know
Offline assertions for one supplied response. Equality compares JSON values and ignores object key order. No test code or network request is executed.
Sources and implementation notes
Implemented by DevBricks Technologies. Method notes updated . References describe the underlying format, method or API. Local processing runs on your device. Any public provider queries are described above and start when you run the lookup.
Work with structured data without losing meaning
Keep a copy of the original document before formatting or converting it. Identify whether the input is one object, an array, or a stream of separate records: these are different structures. JSON uses double quotes for strings and property names, and does not support comments, trailing commas or undefined values. A document that parses successfully can still contain the wrong fields or values for your application.
Inputs and settings explained
- JSON response
- Supply the JSON shape named by this label. Preserve property names and value types in the example, then replace the demonstration data. Objects, arrays and newline-delimited records are different formats; use the one requested rather than enclosing arbitrary text in braces.
See the demonstration value
{ "items": [ { "id": 7 } ], "active": true } - JSON assertion list
- Supply the JSON shape named by this label. Preserve property names and value types in the example, then replace the demonstration data. Objects, arrays and newline-delimited records are different formats; use the one requested rather than enclosing arbitrary text in braces.
See the demonstration value
[{"path":"/items/0/id","test":"equals","value":7},{"path":"/active","test":"type","value":"boolean"}]
How to review the result
Compare structure as well as appearance. Check whether numbers stayed numbers, null stayed distinct from an empty string, and arrays retained their order. Very large integers require particular care when a JavaScript number parser is involved; use the representation your receiving system expects. Formatting changes whitespace, whereas conversion between formats can change the available data types. Test the result with the actual consumer before replacing a working configuration or API fixture.
- Compare a nested object, an empty array and a non-ASCII string with the original.
- Look for repeated keys, missing required properties and unintended type changes.
- Validate against your application's schema separately when one is available.
Common questions about this workflow
Does valid JSON mean my API request is correct?
No. Parsing checks the JSON syntax. Your API can still reject an unsupported property, an incorrect type, missing authorization or a value outside its allowed range. Compare the output with the endpoint's documented contract.
What should I do when the input fails?
Start with the smallest failing object. Check the reported location and the preceding line for a missing comma, unmatched quote or bracket. Fix the source rather than deleting data merely to make the parser accept it.
Built by DevBricks Technologies. Found an unexpected result in JSON Response Contract Assertions? Report a reproducible example with the tool URL, settings and a small sample that contains no private information.