Get answers your code can parse — JSON, XML, CSV, or Markdown tables. Show a schema, give an example, and constrain the output so you never have to scrape prose for the value you need.
Why: software needs structured data, not a paragraph — naming the exact keys and types stops the model inventing its own shape. When: use it any time the output feeds another program. How: describe the schema and forbid extra prose.
Extract the details into JSON with exactly these keys:
{ "name": string, "price_usd": number, "in_stock": boolean }
Return only the JSON, no markdown fences, no commentary.
Text: "The Bamboo Desk Organizer is $14 and currently available."Why: one filled-in example removes all ambiguity about formatting, far better than describing it in words. When: use it when the schema has enums, nested objects, or a date format the model keeps getting wrong.
Convert each event to JSON like this example:
Input: "Standup at 9am on Mondays"
Output: {"title": "Standup", "time": "09:00", "day": "Mon", "recurring": true}
Input: "Dentist appointment June 3rd at 2:30pm"
Output:Why: JSON is not always the target — config tools want XML, spreadsheets want CSV, humans want a Markdown table. When: pick the format your consumer expects and ask for it explicitly with a tiny example.
Return the three planets as a Markdown table with columns
Name | Distance (AU) | Has rings.
Then repeat the same data as CSV with a header row.
Planets: Earth, Saturn, Mars.Why: even with a perfect prompt the model occasionally adds a stray comma or a "Here is your JSON:" preamble. When: in production, always parse the output in code and retry on failure — never assume it is valid. Where: pair this with a stop sequence (next lesson) to cut off trailing chatter.
Defensive pattern (pseudo-code):
response = call_model(prompt)
try:
data = json.parse(response)
except:
response = call_model(prompt + "\nReturn ONLY valid JSON.")
data = json.parse(response) # retry once, then fail loudly