Getting Structured Data Back

Structured Output

Part of: Computer Vision Basics

"The receipt is from Blue Bottle Coffee and the total appears to be twelve dollars and fifty cents." Lovely for a human. Useless to a program, you can't add up a sentence, store it in a column, or branch on it. To do something with a vision answer you need structured data : JSON with known fields. This lesson turns "feed an image, get a paragraph" into "feed an image, get a clean object your code can use." Ask for JSON, get a string of JSON The simplest approach: tell the model exactly what shape you want , then parse the reply. You describe the fields in the prompt, the model writes JSON as its text response, and you call json.loads() to turn that string into a Python dict. Two things matter in that prompt. First, name the exact fields and their types : vague prompts give vague shapes. Second, say "only the JSON, no other text" so you don't have to strip a "Here's the JSON:" preamble before parsing. Why structured output enables real work Once the answer is a dict, the image becomes a row in a table. Scan 500 receipts, get 500 objects, load them into a spreadsheet, sum the totals. The model did the seeing ; your code does the processing . That division of labor is the whole game i

Challenge: Audit the Model's JSON Receipts