【发布时间】:2021-08-11 06:03:58
【问题描述】:
我有一个这样的 JSON 对象。
{
"test": bla bla bla
}
test 可以是 0 到 120 之间的数字或空字符串。我想使用这样的 JSON 模式来验证这个 JSON 对象。
{
"type": ["number", "string"],
"enum": [""],
"minimum": 0,
"maximum": 120
}
有效
{"test": ""}
{"test": 0}
{"test": 120}
{"test": 3}
无效
{"test": "dfd"}
{"test": -1}
{"test": 675}
什么是正确的 JSON 架构?请帮忙
【问题讨论】:
标签: json jsonschema python-jsonschema