يصف 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"}}}