Read a nested schema as an outline
A recursive walk: objects go into their properties, arrays of objects into their items.
JSON Schema is a standard way to write down the shape of JSON: which keys exist, which are required, what type each has, and which values are allowed. The same schema can steer the model, drive a provider's constrained decoding and check the reply.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write the schema (as a Python dictionary) for an object with a required string city and a required integer days, rejecting any other keys. Print it with json.dumps, compact.
Write required_names(schema) that returns the list of required keys of an object schema, or an empty list if there are none.
Explain it without notes
What are the main parts of a JSON Schema for an object?
What is the difference between a field that is optional and a field that is nullable?
Why are enums important for LLM output?
Why generate schemas from types instead of writing them by hand?
Expected output
customer: object (required)
customer.name: string
customer.email: string (required)
priority: one of low, normal, urgent (required)
tags: list of string
attachments: list of object
attachments[]: object
attachments[].url: string
attachments[].size: integer