Prompt Engineering: Zero to Reliable · Module 2 · Getting unstuck
Getting structured output you can paste into code
6 min read · lesson 5 of 5
To use AI output in a spreadsheet, an app or automation, you need structure — usually JSON. Three rules make JSON output nearly reliable.
- Show the exact schema: give the keys, the types, and one filled example.
- Say 'Return ONLY the JSON, no prose, no code fences.' — then the response is paste-ready.
- Name what to do with missing data: 'If a field is unknown, use null — never invent values.'
Return ONLY valid JSON, no prose, matching:
{"items":[{"name":string,"price_gbp":number,"in_stock":boolean}]}
From the text below. Unknown values → null.
<paste product listing text>Validate on your side anyway: even a 95%-reliable format needs a try/parse in code. Trust, then verify.
Practice
Ask for JSON extraction from any messy text you have — an email, a listing, a form — and paste the result into a JSON formatter to check it.