📄JSON Schema
Also known as JSON Schema Validation, JSON Schema File
JSON that describes what other JSON should look like. Tools use it to check data.
Think of it like
Think of it like a form with rules. The name box must be filled, and the age box must be a number.
Example
A shop's API checks each order against its schema. An order with the price written as the word ten is turned away with a clear error.
Why it matters
It catches bad data at the door. That stops it before it breaks something deep in the program.
Definition
Example code
json
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
},
"required": ["name"]
}Common mistake
Key takeaways
- 1Describes the shape. It lists fields and their types.
- 2Written in JSON. The rules use the same format.
- 3Checks data. Tools flag every mismatch.