Use "type": "object" for keyed JSON structures.
Core object keywords
| Keyword | What it does |
|---|
properties | Declares named fields and their schemas |
patternProperties | Applies schemas to keys matching a regex |
required | Lists fields that must be present |
additionalProperties | Controls unknown keys |
minProperties | Minimum number of properties |
maxProperties | Maximum number of properties |
propertyNames | Schema that every property name must satisfy |
unevaluatedProperties is not supported right now.
If you have a use case that requires it, reach out to us.
Example
{
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1 },
"age": { "type": "integer", "minimum": 0 },
"email": { "type": "string", "format": "email" }
},
"required": ["name", "email"],
"additionalProperties": false
}
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class Payload(BaseModel):
model_config = ConfigDict(extra="forbid")
name: str = Field(..., min_length=1)
age: int = Field(0, ge=0)
email: EmailStr
import { z } from "zod";
const payloadSchema = z
.object({
name: z.string().min(1),
age: z.number().int().min(0).optional(),
email: z.string().email(),
})
.strict();
Set additionalProperties: false when you want strict, predictable output shape.
patternProperties
Use regex-based key validation for dynamic maps:
{
"type": "object",
"patternProperties": {
"^S_[A-Z0-9]+$": { "type": "string" },
"^I_[A-Z0-9]+$": { "type": "integer", "minimum": 0 }
},
"additionalProperties": false
}
Pydantic and Zod examples are omitted here because there is no direct keyword mapping for patternProperties.
title, description, default, and examples
Use annotation keywords to document intent and provide generation hints:
{
"type": "object",
"title": "Customer Profile",
"description": "Customer profile returned by the extraction pipeline.",
"default": {
"name": "Unknown Customer",
"email": "unknown@example.com"
},
"examples": [
{
"name": "Alice Johnson",
"email": "alice@example.com"
}
],
"properties": {
"name": {
"type": "string",
"description": "Full legal name."
},
"email": {
"type": "string",
"format": "email",
"examples": ["alice@example.com"]
}
},
"required": ["name", "email"],
"additionalProperties": false
}
from pydantic import BaseModel, ConfigDict, EmailStr, Field
class Payload(BaseModel):
"""Customer profile returned by the extraction pipeline."""
model_config = ConfigDict(
extra="forbid",
json_schema_extra={
"examples": [
{
"name": "Alice Johnson",
"email": "alice@example.com",
}
]
},
)
name: str = Field(description="Full legal name.")
email: EmailStr = Field(
json_schema_extra={"examples": ["alice@example.com"]}
)
import { z } from "zod";
const payloadSchema = z
.object({
name: z.string().describe("Full legal name."),
email: z.string().email(),
})
.strict()
.describe("Customer profile returned by the extraction pipeline.");
These annotation keywords are ignored by structured generation and do not constrain the output. However, they can influence generation if they are included in the prompt.