【发布时间】:2014-09-05 23:26:19
【问题描述】:
鉴于以下 JSON 模式,是否可以指示“名称”属性应是唯一的(即“元素”数组中不应有两个具有相同“名称”的项目。
{
"root": {
"type": "object",
"properties": {
"elements": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Element Name",
"minLength": 3,
},
"url": {
"type": "string",
"title": "Some URL"
}
}
}
}
}
}
}
我尝试使用 uniqueItems 关键字,但它似乎是为简单的值列表设计的。
【问题讨论】:
-
我猜是通过指定
"uniqueItems": true。之前从未使用过 json-schema.org/example1.html 编辑:ietf 定义:tools.ietf.org/html/… -
问题是 5.3.4.2。成功验证的条件说:“如果它的所有元素都是唯一的,则实例验证成功。”。但是如何定义元素是否唯一?
标签: json jsonschema