json - Json Schema 嵌套属性被忽略
问题描述
我正在尝试使用 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
}
解决方案
这会很痛……错别字……
"properties ":
你的双引号中有一个空格。我花了 5 分钟来锻炼身体!您可以通过将其设置为 false 来测试是否达到了子模式。
"properties ": { "test": false, }
推荐阅读
- python - 从 main 中的类调用函数
- scala - 使用带有子类型参数的超级方法
- python - 将python输出放入数据框中的问题
- matlab - 上下分屏实验
- node.js - 我想在运行 nightmare.js 后获取 gig 中的所有数据,但我不断得到 gig 未定义
- javascript - 将鼠标悬停在 Javascript 和/或 CSS 列表中的相应单词上时,如何显示不同的图像?
- python - 训练和验证的不同 Keras 增强
- oracle - 在 SQL Server 中有一个我想在 Oracle 中复制的计数器
- android - 旋转屏幕时可用蓝牙设备的 ListView 变为空白
- java - Android Firebase:如果 OnCompleteListener 在主应用程序线程上调用,它如何异步工作?