【发布时间】:2015-09-04 14:49:50
【问题描述】:
我想用 JSON 模式数组来描述,它应该由零个或多个预定义值组成。为了简单起见,让我们有这些可能的值:one、two 和 three。
正确的数组(应该通过验证):
[]
["one", "one"]
["one", "three"]
不正确:
["four"]
现在,我知道应该使用"enum" 属性,但我找不到相关信息将它放在哪里。
选项 A("items" 下):
{
"type": "array",
"items": {
"type": "string",
"enum": ["one", "two", "three"]
}
}
选项 B:
{
"type": "array",
"items": {
"type": "string"
},
"enum": ["one", "two", "three"]
}
【问题讨论】:
标签: arrays json enums jsonschema