Search LA24X

Keyboard shortcut: Ctrl / ⌘ + K

Type two characters to search, or explore the library.

Open the topic library →

Privacy choices

Choose what suits you. Reading and tools work without analytics or optional saving.

Necessary — always active

Page delivery, language and privacy preferences.

Advertising

Storage details ↗

Get structured AI JSON and validate what the numbers mean

Define a supported schema, handle refusals and incomplete output, then check business rules beyond successful JSON parsing.

Illustration for Get structured AI JSON and validate what the numbers mean
✓ JSON syntax, schema compliance and factual accuracy are three different checks.✓ A refusal needs an explicit handling path.

In brief

Valid JSON only proves the text can be parsed. A schema adds rules about fields and types; your application still needs to check whether the values are plausible and supported by the input.

This prevents an apparently tidy object from silently becoming an incorrect record in a spreadsheet or database.

Make missing information explicit

For receipt extraction, require a currency and total field but allow an explicit unknown value when the image is unreadable. Do not tell the model to invent a default currency merely to pass validation. Restrict extra fields where supported so downstream code does not depend on arbitrary additions.

Check semantics after parsing

An illustrative object such as {"currency":"USD","total":25.50} is not evidence of a real receipt. Compare the amount with the image, reconcile item totals and check whether taxes or discounts are included. A number is still wrong if it was read from the wrong line.

Fail visibly and safely

Keep the original evidence available under appropriate privacy controls. Route unreadable, refused or inconsistent results for correction instead of converting them to zero. If the schema is unsupported, fix the request using the documentation rather than stripping validation to make a failing call look successful.

Before you act

Supported structured-output features and schema subsets vary by model and API. Handle refusals, errors and incomplete responses instead of treating missing fields as successful empty data.

What to do next

  1. Define the needed fields, types and how unknown values are represented.
  2. Use the provider’s supported structured-output mode and parse its documented result.
  3. Validate values against the source and business rules before storing or acting on them.
You’ve reached the end. Save this guide for later.Back to top ↑