Try the working example Edit in Studio
Practical workflow
Start with an exact field contract
Run the example. The field list requires title:string, priority:string and done:boolean. Every key is required and unexpected keys are rejected.
Try the failure path
Click Try a mismatch, then Check JSON. The result lists missing fields and the unexpected key. Fix the JSON and check again. A passing result checks structure, not whether the values are true.
Use a small primitive interface
JSON-CHECK accepts a SHAPE made of at most twelve name:type entries. Supported types are string, number, boolean, object and array. It does not coerce types, fetch schemas or execute values.
Test adversarial inputs
Check invalid syntax, arrays at the root, null values, missing fields, additional keys and wrong types. Strings containing markup remain data. The input limit is 16,000 characters.
Keep application decisions separate
Only use a checked value after your application also checks ranges, permissions and domain rules. This flat contract is deliberately smaller than full JSON Schema. Object and array contents are not validated recursively.
The bounded model response
{"title":"Review generated output","priority":"high","done":false}Validate exact keys and types with Python
import json
def validate_response(raw):
if len(raw) > 16000:
raise ValueError("Input is too large")
value = json.loads(raw)
expected = {"title": str, "priority": str, "done": bool}
if not isinstance(value, dict) or set(value) != set(expected):
raise ValueError("Unexpected or missing keys")
for key, kind in expected.items():
if type(value[key]) is not kind:
raise ValueError("Wrong type for " + key)
return value
# Domain rules, permissions and factual correctness need separate checks.
# checked = validate_response(generated_json)The fixed AppSPEC template
<?xml version="1.0" encoding="UTF-8"?>
<APP ID="json-contract-lab" NAME="JSON Contract Lab" THEME="modern-minimal" WIDTH="1240px">
<DATA MODE="local" />
<STATE ID="check" NAV="Contract checker" ICON="braces">
<TEXT STYLE="h1" TEXT="Catch data errors before they reach your UI" />
<TEXT STYLE="muted" TEXT="Check generated JSON for syntax, required fields, unexpected keys and wrong top-level types before passing it to an application." />
<JSON-CHECK SHAPE="title:string,priority:string,done:boolean" LABEL="Generated JSON" VALUE="{"title":"Review generated output","priority":"high","done":false}" />
<TEXT STYLE="small" TEXT="Nothing is sent or saved. A passing contract checks structure, not truth or authorization." />
</STATE>
</APP>Reproducible mutation experiment
We ran 105 fixed mutation cases against this built engine. 105 matched the expected accept/reject result. These are synthetic fixtures, not sampled LLM responses or a model accuracy estimate.
| Fixture class | Cases | Matched expectation |
|---|---|---|
| valid | 10 | 10 |
| invalid syntax | 10 | 10 |
| missing field | 30 | 30 |
| wrong type | 30 | 30 |
| extra field | 10 | 10 |
| null field | 10 | 10 |
| markup string | 1 | 1 |
| reserved extra | 1 | 1 |
| root array | 1 | 1 |
| root null | 1 | 1 |
| oversize | 1 | 1 |
Reproduce the test by applying the mutations below to the Python validator. Repeat the browser workflow separately; these data checks do not test layout, permissions or truth.
base = {"title": "Example", "priority": "high", "done": False}
# Valid: base. Invalid: remove each key; add an unexpected key;
# replace title/priority with a number; replace done with "false";
# set title to None; truncate the JSON; use [] or null as root.
# Strings containing markup remain strings and must never be injected as HTML.
# Also exercise Check JSON, Try a mismatch and Load valid example in the browser.Engine SHA-256: 25b2411be4661652bcd5e80fa4f9b85eac3e53a5b868a6b2fff0efaad65deb5d. Fixture SHA-256: 29e2ea03be9bddfa0d142239874eafaaff94ae2c31eb36dd7cb8f8f6b394650f.
Source and scope
This practical engineering exercise teaches a registered AppSPEC capability. It is not evidence of external demand. AppSPEC reference.
Local browser validation only. No persistence, server verification, semantic truth check, recursive JSON Schema, reference fetching or automatic repair.
This example passed browser checks for valid JSON, invalid syntax, missing and extra fields, wrong types, null, markup as data and mobile layout. These checks do not establish customer value.