如何确定方案中的最小数组大小 json
我想制定一个计划 json file.It's 用于产品数组。
方案 json 类似于以下内容:
数组必须包含至少一个元素。 如何定义最小数组?
我需要添加最小定义吗?
方案 json 类似于以下内容:
{
"$schema": "[url=http://json-schema.org/draft-04/schema#"]http://json-schema.org/draft-04/schema#"[/url],
"title": "Product set",
"type": "array",
"items": {
"title": "Product",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "number"
},
"name": {
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"dimensions": {
"type": "object",
"properties": {
"length": {"type": "number"},
"width": {"type": "number"},
"height": {"type": "number"}
},
"required": ["length", "width", "height"]
},
"warehouseLocation": {
"description": "Coordinates of the warehouse with the product",
"$ref": "[url=http://json-schema.org/geo"]http://json-schema.org/geo"[/url]
}
},
"required": ["id", "name", "price"]
}
}
数组必须包含至少一个元素。 如何定义最小数组?
我需要添加最小定义吗?
没有找到相关结果
已邀请:
3 个回复
石油百科
赞同来自:
.
看:
http://tools.ietf.org/html/dra ... 5.3.3
和
http://jsonary.com/documentati ... ation
涵秋
赞同来自:
仅适用于数值,而不是数组。
5.1. 检查数值实例的关键字 /number 和 integer/
...
http://tools.ietf.org/html/dra ... 5.1.3
所以你必须善于 min/maxItems 对于数组。
小姐请别说爱
赞同来自:
http://json-schema.org/example1.html
:
请注意,属性 "tags" 定义为具有最小项目数的数组 /1/.