它是一个有效的json架构:
object:
$ref: '#/definitions/object'
Run Code Online (Sandbox Code Playgroud)
你会建议使用这种格式吗?
Jas*_*ers 11
自我引用是允许和有用的.但是,您的示例看起来只是一个参考无限循环.下面是一个JSON模式的示例,它使用递归引用来定义无限深度的树结构.
{
"type": "object",
"properties": {
"name": { "type": "string" },
"tree": { "$ref": "#/definitions/tree" }
},
"definitions": {
"tree": {
"type": "object",
"properties": {
"value": { "type": "string" },
"branches": {
"type": "array",
"items": { "$ref": "#/definitions/tree" },
"minItems": 1
}
},
"required": ["value"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5311 次 |
| 最近记录: |