API Documentation
Schema Documentation
Arrays
Arrays in JSON Schema allow you to define lists of items. The AI will extract matching items and arrange them in a structured array.
Basic Arrays
To define an array, use "type": "array"
and specify the structure of each item using the items
property.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The person's name" }, "hobbies": { "type": "array", "description": "List of the person's hobbies", "items": { "type": "string" } } } }
Example Input:
Alex enjoys reading books, playing piano, and hiking on weekends.
Example Output:
{ "name": "Alex", "hobbies": [ "reading books", "playing piano", "hiking" ] }
Pro Tip:
The AI will automatically detect lists within text, even when presented in different formats like comma-separated values, bulleted lists, or natural language.
Arrays of Objects
You can create arrays containing complex objects, which is useful for extracting structured data about multiple entities.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The person's name" }, "skills": { "type": "array", "description": "List of the person's skills with experience levels", "items": { "type": "object", "properties": { "skillName": { "type": "string", "description": "Name of the skill" }, "yearsExperience": { "type": "number", "description": "Years of experience with this skill" }, "level": { "type": "string", "description": "Skill level (e.g., beginner, intermediate, advanced)" } }, "required": ["skillName"] } } } }
Example Input:
Sarah has the following skills: JavaScript (5 years, advanced), Python (3 years, intermediate), and HTML/CSS (7 years, expert).
Example Output:
{ "name": "Sarah", "skills": [ { "skillName": "JavaScript", "yearsExperience": 5, "level": "advanced" }, { "skillName": "Python", "yearsExperience": 3, "level": "intermediate" }, { "skillName": "HTML/CSS", "yearsExperience": 7, "level": "expert" } ] }
Nested Arrays
Arrays can be nested within other arrays, allowing for complex hierarchical data structures.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The company name" }, "departments": { "type": "array", "description": "List of departments in the company", "items": { "type": "object", "properties": { "departmentName": { "type": "string", "description": "Name of the department" }, "employees": { "type": "array", "description": "List of employees in this department", "items": { "type": "string", "description": "Employee name" } } } } } } }
Example Input:
Acme Corp has three departments: Engineering (with employees John, Maria, and Alex), Marketing (with employees Sarah and David), and HR (with employee Michael).
Example Output:
{ "name": "Acme Corp", "departments": [ { "departmentName": "Engineering", "employees": [ "John", "Maria", "Alex" ] }, { "departmentName": "Marketing", "employees": [ "Sarah", "David" ] }, { "departmentName": "HR", "employees": [ "Michael" ] } ] }
Array Constraints
You can add constraints to arrays to specify the minimum and maximum number of items they should contain.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The person's name" }, "topFiveMovies": { "type": "array", "description": "Person's top five favorite movies", "items": { "type": "string" }, "minItems": 1, "maxItems": 5 } } }
Example Input:
James loves movies. His favorites are The Godfather, Pulp Fiction, and The Dark Knight. He also likes Inception.
Example Output:
{ "name": "James", "topFiveMovies": [ "The Godfather", "Pulp Fiction", "The Dark Knight", "Inception" ] }
Note:
When using minItems
and maxItems
, the AI will try to extract the specified number of items, but the actual number may vary based on what's available in the input text.
Unique Items
You can ensure all items in an array are unique by setting uniqueItems
to true
.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The product name" }, "tags": { "type": "array", "description": "Unique tags associated with the product", "items": { "type": "string" }, "uniqueItems": true } } }
Example Input:
The "Ultra Blender" is tagged with: kitchen, blender, kitchen appliance, high-power, blender, modern.
Example Output:
{ "name": "Ultra Blender", "tags": [ "kitchen", "blender", "kitchen appliance", "high-power", "modern" ] }
Pro Tip:
When uniqueItems
is set to true
, the AI will deduplicate items with the same value, keeping only one occurrence.