PassaTime
All stories
AI HELP · STRUCTURED DATA 2026-10-14

AI returned valid JSON. That does not make its facts correct.

Check syntax, required fields and types, then compare the values with their source. Each check answers a different question.

Separate “can the program read it?” from “does it contain the right information?” A machine-readable response can still have a missing field, a number stored as text or a fact that does not match the source.

Use a small explicit contract

Our invented source says city Seoul and count 2. For this task, require city as a string and count as a non-negative integer, with no other fields. The JSON Schema guide explains that properties are optional by default; required and additionalProperties express separate constraints.

Test an answer that looks reasonable

{"city":"Busan","count":2} parses as JSON and passes our simple field checks, but its city contradicts the invented source. {"city":"Seoul","count":"2"} parses too, but fails the integer check. An object containing only city fails the required-field check.

Ask the AI to preserve unknowns

Specify the field names, allowed types and how unavailable information should be represented. If null is allowed, include it in the contract explicitly; null and an absent field are different cases. Do not ask the model to invent a value just to complete the shape.

Keep the checks outside the model

Parse and validate the result in the receiving program, then verify important values against the evidence. For a real integration, use a validator compatible with the schema version and constraints you chose. Our small check function is not a complete JSON Schema implementation.

Published October 14, 2026. JSON parsing and a custom field checker were executed on original fictional examples. No AI API or full JSON Schema validator was run.

Sources: JSON Schema · Objects.