JSON & Schema
JSON Schema Arrays
An array schema describes both the collection and its members. Use items for a repeated item schema and collection keywords for length or uniqueness rules.
Published
Smallest useful schema
Describe the collection, then its items
{ "type": "array" }{
"type": "array",
"items": { "type": "string" }
}Live validation task
Diagnose one invalid array item
The third item violates the repeated string item schema.
Schema: { "type": "array", "items": { "type": "string" } }
Data: ["red", "blue", 42]Expected result: The real validator reports the numeric item at index 2; changing 42 to "42" makes the data valid.
After the failing item is fixed
Add only the constraints the data needs
Arrays of objects
Put object properties under the item schema, not directly on the array.
Collection limits
Use minItems, maxItems and uniqueItems for list-level rules.
Tuple-style data
In draft 2020-12, prefixItems describes fixed leading positions.
Practice with the full tool
Validate your array schema
Use your own schema and JSON data to inspect item-level validation errors and paths.