JSON 架构:数组项的定义
JSON Schema: Definitions for array items
我正在尝试在 JSON 架构中定义一个数组元素。它们的数组包含来自已在架构的 definitions
部分中定义的类型的项目。
我试过:
"properties": {
"userId": {"$ref": "#/definitions/userId"},
"beacons": {
"type": "array",
"items": { "$ref": "#/definitions/beaconSchema" }
}
}
userId
部分用#/definitions/userId
解析。但是,列表项会忽略 #/definitions/beaconSchema
并允许其中包含任何旧垃圾。
如何使用 JSON 架构 definition
解析 JSON 数组中的所有项目?
您发布的架构片段是正确的。我建议您在 $ref
路径和定义 属性 名称中查找拼写错误。如果您在那里没有发现问题,请尝试发布更多架构。
我正在尝试在 JSON 架构中定义一个数组元素。它们的数组包含来自已在架构的 definitions
部分中定义的类型的项目。
我试过:
"properties": {
"userId": {"$ref": "#/definitions/userId"},
"beacons": {
"type": "array",
"items": { "$ref": "#/definitions/beaconSchema" }
}
}
userId
部分用#/definitions/userId
解析。但是,列表项会忽略 #/definitions/beaconSchema
并允许其中包含任何旧垃圾。
如何使用 JSON 架构 definition
解析 JSON 数组中的所有项目?
您发布的架构片段是正确的。我建议您在 $ref
路径和定义 属性 名称中查找拼写错误。如果您在那里没有发现问题,请尝试发布更多架构。