如何让用户在JSON Schema中输入项目列表?

时间:2013-07-22 15:06:46

标签: json jsonschema

如何在JSON Schema中指定用户验证项目列表(如字符串)的结构?

这是我到目前为止所做的:

"list_of_str": {
    "type": "array",
    "items": {
         "type": "string"
    }
}

提前致谢!

1 个答案:

答案 0 :(得分:1)

>>> res = {
...     "type": "array",
...     "items": {
...          "type": "string"
...     }
... }
>>> 
>>> one = ["one", "two"]
>>> 
>>> 
>>> validictory.validate(one, res)
>>> # No error

“validictory是一个通用的Python数据验证器,允许验证任意Python数据结构。” (见这 - > Validictory docs