Sebuah tipe | Kata kunci | Contoh / Deskripsi |
---|
"Kata kunci" untuk menggambarkan skema | "$schema" | "$schema": http:
Digunakan untuk mengatur versi konsep skema. |
"$id"
| "$id": "http://archi-blair.com/schemas/RolesDictionaryDef.json#"
Digunakan untuk menunjukkan pengidentifikasi unik untuk dokumen atau subcircuits-nya. |
"title" "description" "examples" "comment"
| {
"title": "JSON schema for dictionary",
"description": " ",
"examples": ["user", "manager"],
"comment": " ))"
}
|
Umum "Kata kunci validasi" independen dari jenis data item | "enum" | {"enum": [ "administrator", "superuser" ]}
Cek dibuat untuk mencocokkan setidaknya 1 nilai.
|
"const" | {"const": "user" }
Pemeriksaan dilakukan untuk kepatuhan yang tepat dengan nilai yang ditetapkan.
|
"type" | {"type": ["number", "string", "null", "boolean"]}
{"type": "array"}
Menentukan jenis data yang akan digunakan skema. Kata kunci ini adalah opsional, dan nilai kata kunci dapat berupa string yang mewakili tipe data yang valid atau array string yang mewakili tipe data yang valid.
|
Keywords, , | "type": "string"
minLength maxLength pattern contentEncoding contentMediaType
| {
"type": "string",
"minLength": 3,
"maxLength": 10,
"pattern": "^test\\/[a-z-]+$",
"contentEncoding": "base64",
"contentMediaType": "application/json"
}
.
|
"type": "number" "type": "integer"
minimum exclusiveMinimum maximum exclusiveMaximum multipleOf
| {
"type": "number",
"minimum": 1.5,
"exclusiveMinimum": true,
"maximum": 12.3,
"exclusiveMaximum": true,
"multipleOf": 0.5
}
.
|
"type": "object"
properties required dependencies minProperties maxProperties propertyNames patternProperties additionalProperties
|
"employees": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": ["employee"],
"enumNames": [""]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
, ( ).
|
"type": "array"
minItems maxItems uniqueItems contains items additionalItems
|
"employees": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": ["employee"],
"enumNames": [""]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
, ( ).
|
"type": "boolean"
| {"type": "boolean"}
boolean (true false).
|
"type": "null"
| {"type": "null"}
null «» .
|
"type": "____" "format": "____"
| {
"type": "string",
"format": "date"
}
format . , .. -, , , .
|
"type": "____" "default": "____"
| {
"enabled": {
"type": "boolean",
"default": true
}
.
, .
|
| "not" "if-then-else"
| {
"not": {
"type": "string"
}
}
, .
|
, | "anyOf" "oneOf" "allOf"
| {
"type": "string",
"anyOf": [
{"const": "user"},
{"const": "manager" }
]
}
, .
|
, | "$id" "$ref" | RolesDictionaryDef.json:
{
"$id": http:
}
1 $ref ( ):
"items": {
"type": "object",
"minLength": 1,
"properties": {
"name": {
"description": " ",
"type": "string"
},
"description": {
"description": " ",
"type": "string"
},
"dictionaryGroup": {
"$ref": "RolesDictionaryDef.json#/definitions/roles"
}
},
"additionalProperties": false
}
2 JSON. , $ref .
|
"$ref" "definitions" | "$ref": "#/definitions/roles" , «definitions»:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": " ",
"type": "object",
"properties": {
"dictionaries": {
"description": "",
"type": "array",
"maxItems": 1,
"items": {
"type": "object",
"minLength": 1,
"properties": {
"name": {
"description": " ",
"type": "string",
"enum": [
"Roles Dictionary"
]
}
"dictionaryGroups": {
"$ref": "#/definitions/roles",
"description": " "
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false,
"definitions": {
"roles": {
"description": "",
"type": "object",
"properties": {
"administrators": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": [
"administrator",
"superuser"
],
"enumNames": [
"",
"- "
]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"$id": "http://archi-blair.com/schemas/RolesDictionaryDef.json#"
}
, . $ref definitions.
|
"$ref" .
| "$ref": " #/definitions/roles"
"$ref": "RolesDictionaryDef.json#/definitions/roles"
, . , .
|