Validate AI JSON against a schema you already wrote for one instance
Write a schema and one valid instance first. Keep chat JSON only when it validates and matches the instance rules.
In short
- Write a JSON Schema (or equivalent) and one valid instance before reading the chat.
- Validate with a real validator mindset: required keys, types,
additionalProperties. - Keep only when validation passes and values match your sheet.
Example sheet instance: {"sku":"RICE-5KG","qty":2} with qty a number, no extra keys.
Write schema + instance
Draft schema shape used on 3 December 2026 for this article:
{
"type": "object",
"required": ["sku", "qty"],
"properties": {
"sku": { "type": "string" },
"qty": { "type": "number" }
},
"additionalProperties": false
}
{"sku":"RICE-5KG","qty":"2"} fails the type check even though it “looks right.”

Strings that look like numbers
qty: "2" parses as JSON and fails the schema. Extra "ok": true fails additionalProperties: false. Same family of traps as AI JSON known object.

Ask, then validate
Return one JSON object matching this schema and instance intent:
sku string RICE-5KG, qty number 2, no other keys.
I will reject string qty and extra properties.

Related
Share