假设我正在编写一个 JSON 模式。“类型”是“对象”。在对象的“属性”中包含名为“描述”的属性是否合法?我问是因为“描述”是 JSON 模式中的关键字。
示例:在此示例中,我为表示葡萄酒年份的 JSON 对象提供了一个简单的模式。我指定了四个属性:三个必需属性(房子、年份和葡萄品种)和一个可选属性,名为“description”。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Wine vintage",
"description": "JSON schema for wine vintages",
"type": "object",
"properties": {
"house": {
"description": "The name of the house that made the wine",
"type": "string"
},
"year": {
"description": "The year in which the wine was made",
"type": "integer"
},
"varieties": {
"description": "The grape varieties used to make the wine",
"type": "array",
"items": {
"type": "string",
"minItems": 1,
"uniqueItems": true
}
}
"description": {
"description": "A description of the wine's taste and character; a tasting note",
"type": "string"
}
},
"required": ["house", "year", "varieties"]
}