Draft 2019-09 - Array Example
A schema describing fruits and vegetables
$id | https://example.com/arrays.schema.json |
$schema | https://json-schema.org/draft/2019-09/schema |
Properties
Example
{
"fruits": [
"Apple"
],
"vegetables": [
{
"name": "Tomato",
"hasARoundShape": true
},
{
"name": "Carrot",
"hasARoundShape": false
}
]
}
fruits
Title |
Fruits |
Description |
An array of fruit names |
Type | Array |
Required |
No |
Contains |
Type: string |
vegetables
Title |
Vegetables |
Description |
An array vegetable objects |
Type | Array |
Required |
No |
vegetables.name
Title |
Name |
Description |
The name of the vegetable. |
Type | String |
vegetables.hasARoundShape
Title |
Is round |
Description |
Does this vegetable have a round shape? |
Type | Boolean |
Schema
{
"$id": "https://example.com/arrays.schema.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"title": "Draft 2019-09 - Array Example",
"description": "A schema describing fruits and vegetables",
"examples": [
{
"fruits": [
"Apple"
],
"vegetables": [
{
"name": "Tomato",
"hasARoundShape": true
},
{
"name": "Carrot",
"hasARoundShape": false
}
]
}
],
"type": "object",
"properties": {
"fruits": {
"title": "Fruits",
"description": "An array of fruit names",
"type": "array",
"contains": {
"type": "string"
}
},
"vegetables": {
"title": "Vegetables",
"description": "An array vegetable objects",
"type": "array",
"items": {
"$ref": "#/$defs/vegetable"
}
}
},
"$defs": {
"vegetable": {
"type": "object",
"required": [
"name",
"hasARoundShape"
],
"properties": {
"name": {
"type": "string",
"title": "Name",
"description": "The name of the vegetable."
},
"hasARoundShape": {
"type": "boolean",
"title": "Is round",
"description": "Does this vegetable have a round shape?"
}
}
}
}
}