Ask for structure. Then validate it.
JSON-looking text is not the same as a reliable data pipeline.
Structured outputs make model responses easier to inspect and use, but a prompt alone cannot guarantee valid JSON or true facts.
Make the shape explicit
Specify required keys, expected types, how to represent unknown values, and whether extra keys are allowed. A short example can reduce ambiguity, but can also bias the model to copy its values. Test with different inputs.
Check syntax and meaning separately
- Parse the output with a real JSON parser. Do not execute it as code.
- Validate its structure against your application's schema.
- Verify evidence and factual values against the original source.
- Check application-specific rules, such as whether dates are valid and amounts have units.
A valid object containing a fabricated date still fails. An exact quote that doesn't support the extracted value also fails.
Use null intentionally
“Unknown,” an empty string, zero, and JSON null mean different things. Decide which one your system expects. The extraction template uses null for absent or ambiguous fields and a warnings array for conflicts.
Prefer provider-enforced schemas when available
Some model APIs support schema-constrained generation. Use those controls when appropriate, then validate the result anyway. They constrain form, not factual correctness. This workbench only prepares plain-text prompts; it does not configure API response schemas.
Design a safe failure path
If parsing or validation fails, stop before the result changes external state. Keep enough non-sensitive diagnostic information to debug it. If you retry, cap the retries and avoid feeding secrets into error messages. A human review step is often a better first version than unattended automation.