As soon as anything other than a human reads the output — a script, a database, another step in a workflow — prose becomes a liability. You need a shape.
Name every field
"Return JSON" is not a specification. This is:
Return only a JSON object with these fields:
title(string): the headline, verbatimpublished(string or null): ISO dateYYYY-MM-DD, or null if not statedtopics(array of strings): at most three, lower caseconfidence(number): 0 to 1No text before or after the JSON.
Every field has a name, a type and a rule. published has an explicit null case. topics has a cap and a casing rule. The last line handles the most common annoyance — a friendly sentence wrapped around the JSON that breaks your parser.
Always give "I don't know" a home
This is the highest-value line in this lesson. A model completes plausible text. If your schema has a price field and the document contains no price, the most plausible completion is a price, because that is what the field is for.
Add an explicit escape — null, "unknown", an empty array — and say when to use it. You are not making the model more honest; you are giving the honest answer a legal shape to arrive in.
Plan for it breaking
Even with a good schema, output occasionally arrives malformed — truncated because it hit a length limit, wrapped in a code fence, or with a trailing comma. Treat parsing as something that can fail:
- Validate, do not trust. Parse into a schema and check the types. Never feed unvalidated model output straight into something that acts on it.
- Retry once, with the error. Handing back "that was not valid JSON: unexpected end of input" fixes a large share of failures.
- Have a fallback. Decide in advance what happens on a second failure. Surfacing an honest error beats storing a broken record.
Length limits truncate structure
A response that runs into the output limit stops mid-token, which for JSON means an unclosed brace and a parse error. If you are seeing intermittent truncation, the cause is usually a schema that is too large for the room you gave it — cap array lengths, split the work, or raise the limit.
When not to bother
If a person is reading the answer, structure often makes it worse. Forcing a nuanced explanation into rigid fields strips exactly the qualifications that made it useful. Use structure when something downstream needs to parse it. Use prose when a human needs to understand it.