如何让用户在JSON模式中输入项目列表?
如何指定一个结构来验证JSON模式中的用户的项目列表(比如字符串) 这就是我到目前为止所做的:如何让用户在JSON模式中输入项目列表?,json,jsonschema,Json,Jsonschema,如何指定一个结构来验证JSON模式中的用户的项目列表(比如字符串) 这就是我到目前为止所做的: "list_of_str": { "type": "array", "items": { "type": "string" } } 提前谢谢 >>> res = { ... "type": "array", ... "items": { ... "type": "string" ... } ...
"list_of_str": {
"type": "array",
"items": {
"type": "string"
}
}
提前谢谢
>>> res = {
... "type": "array",
... "items": {
... "type": "string"
... }
... }
>>>
>>> one = ["one", "two"]
>>>
>>>
>>> validictory.validate(one, res)
>>> # No error
“Validitory是一个通用Python数据验证器,允许对任意Python数据结构进行验证。”(请参见此->)
“Validitory是一个通用Python数据验证器,允许对任意Python数据结构进行验证。”(请参见此->)谢谢Alberto!非常有用。我们将研究这个简单的验证器。这里有一个非常好的教程,到目前为止,您一直在使用jsonschema中的“validate”。是的,Validitory使用从jsonschema派生的代码:)我认为它非常简单而且功能强大!谢谢阿尔贝托!非常有用。我们将研究这个简单的验证器。这里有一个非常好的教程,到目前为止,您一直在使用jsonschema中的“validate”。是的,Validitory使用从jsonschema派生的代码:)我认为它非常简单而且功能强大!