Mah*_*aha 7 json jsonschema json-schema-validator
我们可以强制类型对象的空属性如下:
{
"description": "voice mail record",
"type": "object",
"additionalProperties": false,
"properties": {}
}
Run Code Online (Sandbox Code Playgroud)
为解释在这里.
现在我要验证属性哪个
执行非空虚(第4点)是我无法猜测的.这与执行空虚有些相反,如上例所示.我当前的json架构摘录如下所示:
"attribute":
{
"type": "object",
"additionalProperties": { "type": ["string","number","integer"] }
}
Run Code Online (Sandbox Code Playgroud)
但上面并没有强制执行非空虚.我怎么能做到这一点?
clo*_*eet 14
听起来像是minProperties你想要的.
{
"type": "object",
"additionalProperties": {"type": ["string", "number", "integer"]},
"minProperties": 1
}
Run Code Online (Sandbox Code Playgroud)
还有maxProperties,可以作为您链接的相反问题的替代解决方案.
| 归档时间: |
|
| 查看次数: |
1490 次 |
| 最近记录: |