【发布时间】:2018-10-21 23:40:21
【问题描述】:
我正在尝试使用 json Schema,但我似乎遗漏了一些东西。 我在“测试”中设置的所有内容都被完全忽略了。我可以将类型设置为任何类型,它仍然被接受。如何验证这些嵌套属性?
forward_schema = {
"$schema": "http://json-schema.org/draft-06/schema#",
"title": "ForwarderObject",
"description": "All Forwarding Settings",
"type": "object",
"properties": {
"active": {
"type": "boolean",
},
"groups": {
"type": "object",
"title": "groups",
"properties ": {
"test": {
"type": "something",
},
},
"required": ["test"]
},
},
"required": ['active', "groups"],
}
test_object = {
'groups':
{
'test':
{
'from': ['1240321726a'],
'to': ['225388559'],
'filters':
{
'Asserter':
{
'regex': ['"1232/"', '2aa']
}
},
'group-name': 'test',
'label': '',
'edited': ''
},
},
'active': true
}
【问题讨论】:
-
Ty,确实很痛
-
您可以选择以拼写错误为由删除您的问题。通常认为在 SO 上做正确的事情。但总是问更多问题=]
-
澄清一下!
-
请随时将我的答案标记为已接受的答案
标签: json validation schema jsonschema json-schema-validator