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.

Published 2026-12-03 · Translation: VI

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.”

Known instance with numeric qty before trusting the chat.

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.

Numeric qty kept; string qty discarded.

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.

Write schema → ask → validate → match.

Share

X Facebook LinkedIn
Educational content only. Rankings reflect stated criteria at the update date—not investment advice or permanent performance guarantees.