Php Json模式-验证无限递归结构
我正在尝试使用php的“jastinrainbow/json模式”包验证json对象 以下是我试图验证的json:Php Json模式-验证无限递归结构,php,json,validation,jsonschema,Php,Json,Validation,Jsonschema,我正在尝试使用php的“jastinrainbow/json模式”包验证json对象 以下是我试图验证的json: { "questions": [ { "type": "section", "name": "Section one", "questions": [ { "type": "section", "name": "Subsection 1.
{
"questions": [
{
"type": "section",
"name": "Section one",
"questions": [
{
"type": "section",
"name": "Subsection 1.1"
"questions":[
{
"type": "section",
"name": "Subsection 1.1"
"questions":
[
{
...
}
]
}
]
}
]
}
]
questions属性始终可以出现在questions属性中。。。。
我如何验证它
感谢您的回答您可以使用
$ref
定义递归结构
{
"type": "object",
"properties": {
"type": { "type": "string" },
"name": { "type": "string" },
"questions": { "type": "array", "items": { "$ref": "#"} }
}
}
可能重复的