Skip to content
Valery

Module 2 · Lesson 5 of 6

Structured outputs

JSON and schemas in plain words, extracting fields from a fictional agreement summary, validation, and handling missing fields.

8 min

Most of what you've asked models for so far is prose: an email, a description, a summary. Prose is for people. When a model's output needs to go somewhere else, into a CRM field, a deal checklist, a spreadsheet or the next step of a workflow, it needs to be structured: the same fields, in the same places, every time. This lesson explains structured output in plain words, shows how to extract fields from a fictional agreement summary, and covers the part that matters most at a brokerage: what to do when a field is missing.

JSON in plain words

Key term
JSON

A plain-text format for structured data, made of named fields and their values. Nearly every app, CRM and automation tool can read it. It is pronounced "jay-son".

JSON looks like this:

{
  "property_address": "456 Sample Avenue, Hamilton, Ontario",
  "purchase_price": 812000,
  "conditions": ["financing", "home inspection"],
  "completion_date": null
}

Read it line by line:

  • Each line has a field name in quotes, a colon, then a value.
  • Text values sit in quotes; numbers don't (and have no dollar signs or commas).
  • Square brackets hold a list of values.
  • null means "no value": the field exists but is empty. You will lean on it heavily.
  • Curly braces wrap the whole record.

You will rarely type JSON yourself. You need to read it well enough to spot a wrong value, and to tell a developer or a coding agent what fields you want.

Schemas: the shape you require

A schema describes the shape the output must have: which fields exist, what type each one is (text, number, date, list), which are required, and which values are allowed. It is the contract between the model and whatever reads its output next.

As of October 2026, the major vendors can enforce a schema for you. Anthropic's structured outputs feature uses constrained decoding so Claude's responses always match the schema you supply; OpenAI's Structured Outputs ensures responses adhere to your JSON Schema; and Google AI Studio has a structured output setting in its run settings panel. With these turned on, broken JSON and missing required fields become very rare; the exceptions vendors list include a reply cut off at its length limit or a refusal.

Here is the catch: a valid shape isn't a correct value. A schema guarantees a completion_date field exists. It can't guarantee the date is right, or that it came from the document rather than from the model's imagination. That is what validation and human review are for.

Worked example: extracting an agreement summary

In Ontario, most resale deals use the Ontario Real Estate Association's Agreement of Purchase and Sale (OREA Form 100), and Module 7 covers offer preparation in detail. Here, an admin at the fictional Maple & Main Realty wants the key terms of an accepted deal pulled into the brokerage's deal tracker. The input is a fictional summary an agent typed up:

AGREEMENT OF PURCHASE AND SALE: SUMMARY (fictional)
Property: 456 Sample Avenue, Hamilton, Ontario
Purchase price: $812,000
Deposit: $40,000, payable to Maple & Main Realty Inc., Brokerage,
in trust, within 24 hours of acceptance
Irrevocable: until 11:59 p.m. on October 24, 2026
Accepted: October 24, 2026
Conditions: financing, 5 banking days after acceptance;
home inspection, 5 banking days after acceptance
Chattels included: fridge, stove, washer, dryer, all window coverings
Fixtures excluded: dining room chandelier
Rental items: hot water tank, assumed by buyer
Completion date:

The admin defines the fields the tracker needs:

FieldTypeRule
property_addresstextRequired. Copy exactly.
purchase_pricenumberRequired. Digits only.
deposit_amountnumberRequired. Digits only.
deposit_timingtextCopy the wording exactly.
acceptance_datedateAs written, in year-month-day form.
completion_datedate or nullNull if not stated. Never estimate.
conditionslistEach with its type and its deadline wording, copied exactly.
chattels_included, fixtures_excluded, rental_itemslistsCopy each item.
missing_fieldslistNames of required fields not found in the source.

The instruction to the model is short, because the schema does most of the work:

Extract the fields defined in the schema from the <summary> below.
Copy wording exactly where the schema says so. Use null for any
field the summary does not state, and list it in missing_fields.
Never infer, estimate or fill in typical values.

And the output:

{
  "property_address": "456 Sample Avenue, Hamilton, Ontario",
  "purchase_price": 812000,
  "deposit_amount": 40000,
  "deposit_timing": "within 24 hours of acceptance",
  "acceptance_date": "2026-10-24",
  "completion_date": null,
  "conditions": [
    { "type": "financing", "deadline": "5 banking days after acceptance" },
    { "type": "home inspection", "deadline": "5 banking days after acceptance" }
  ],
  "chattels_included": ["fridge", "stove", "washer", "dryer", "all window coverings"],
  "fixtures_excluded": ["dining room chandelier"],
  "rental_items": ["hot water tank, assumed by buyer"],
  "missing_fields": ["completion_date"]
}

Notice what the model did not do. It didn't convert "5 banking days after acceptance" into a calendar date (holidays and the exact acceptance time matter, and a person should do that). It didn't guess a completion date. And it didn't extract the buyers' and seller's names, because the tracker doesn't need them and the summary didn't include them: a context-engineering choice from Lesson 3.

Validation: checking the values

After extraction, run checks before anything is saved. Some are simple rules a workflow tool can apply; others need a person.

CheckWhyExample it catches
Required fields present or listed as missingNothing silently blankA missing price
Deposit is less than the priceCatches swapped numbersDeposit of 812000
Dates in a sensible orderAcceptance on or before the irrevocable deadline; completion after acceptanceA completion date before acceptance
Address matches the listing recordCatches the wrong fileA neighbouring unit number
Every number appears in the source textCatches invented valuesA deposit of 41,000 that isn't in the summary
Person reviews flagged itemsJudgement callsCondition deadlines that need calendar dates

The "appears in the source" check is the most powerful one for catching hallucinated values, and it is easy to automate: if the number 40000 (or 40,000) isn't in the original text, stop and flag it.

When a field is missing

A missing field is normal: summaries are incomplete, scans are blurry, and agents forget a line. What matters is that a missing value stays visibly missing.

  1. Return null, never a guess. A model asked for a completion date with none in the text will often supply a plausible one, such as 60 days after acceptance, unless you forbid it. Forbid it.
  2. List what's missing. A missing_fields list lets the workflow route the record to a person automatically.
  3. Ask the right person. The workflow sends the agent a message: "The summary for 456 Sample Avenue has no completion date. Please add it to the deal file."
  4. Never default to "typical" values. A typical deposit percentage or closing period is not this deal's term.
Deal intake with structured extraction
  1. 1. DataAgent uploads the agreement summary
  2. 2. AIExtract fields to the schema
  3. 3. CheckValidation rules run
  4. 4. HumanAdmin reviews flags and missing fields
  5. 5. StoreDeal tracker updated
  6. 6. ActionAgent asked for anything missing

In practice

Maple & Main's admin, Sam, used to retype deal terms from agents' summaries into the tracker: about ten minutes a deal, with the occasional transposed digit. With the extraction step, the fields arrive filled, the validation checks run, and Sam reviews a short list of flags instead of retyping everything. On the first day, the "appears in source" check catches one deposit the model read as $45,000 from a smudged scan that actually said $40,000. Sam fixes it from the original and notes the scan quality in the deal file. Retyping is gone; checking stays.

Common mistakes

  • Trusting a valid JSON shape as proof the values are right.
  • Letting the model convert deadlines into calendar dates without a person checking.
  • Allowing "best guess" values instead of null.
  • Extracting personal details the destination system doesn't need.
  • Skipping the "does this value appear in the source?" check.

Key takeaways

  • Structured output means the same named fields every time, usually as JSON, so other systems can use it.
  • A schema defines the fields, types and required values; vendors can enforce it, as of October 2026.
  • Schema enforcement guarantees shape, not truth. Validate values against the source.
  • Missing information must stay missing: null, listed, and routed to a person.
  • Extract only the fields the destination needs.

Finished reading? Move on when you're ready.