JSON Schema อธิบายรูปร่างของข้อมูล JSON และตรวจสอบเอกสารอัตโนมัติ
type จำกัดชนิด properties กำหนดฟิลด์ required ระบุคีย์ที่ต้องมี items อธิบายสมาชิกอาร์เรย์
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["name", "age"],
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0}
}
}
enum อนุญาตชุดค่าคงที่ const ต้องการค่าเดียว
{"role": {"enum": ["admin", "editor", "viewer"]}}
$ref ชี้ไปยังนิยามอื่นเพื่อให้เอกสารซับซ้อนดูแลง่าย
{"$defs":{"id":{"type":"integer"},"type":"object","properties":{"id":{"$ref":"#/$defs/id"}}}