我有一个这样的字典列表:
list_of_dictionaries = [{'key1': True}, {'key2': 0.2}]
Run Code Online (Sandbox Code Playgroud)
我想使用 jsonschema 包来验证它。
我创建了这样的架构:
schema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"key1": {
"type": "boolean"
},
"key2": {
"type": "number"
}
},
"required": ["enabled"]
}
}
Run Code Online (Sandbox Code Playgroud)
但这对于我的列表来说是不正确的,因为要使其正常工作,我的列表应该是这样的:
list_dict = [{'key1': True, 'key2': 0.5}]
Run Code Online (Sandbox Code Playgroud)
如何创建正确的架构来验证我的列表?先感谢您。