【发布时间】:2019-01-28 21:31:32
【问题描述】:
我想使用模式验证 JSON(目前是草案 6,但如果需要我们可以升级)。我的案例是一个具有属性的对象,其值都具有相同的结构,例如:
{
"blueFoo": {
"bar1": "someValue",
"bar2": "differentValue"
},
"redFoo": {
"bar1": "someOtherValue",
"bar2": "LoremYpsum"
},
"purpleFoo": {
"bar1": "anotherString",
"bar2": "nextValue"
},
...
}
有没有办法为通用属性值设置验证模式?比如:
{
"type": "object",
"propertyValue": {
"type": "object",
"required": ["bar1", "bar2"],
"additionalProperties": false,
"properties": {
"bar1": {"type": "string"},
"bar2": {"type": "string"}
}
}
}
谢谢。
【问题讨论】:
标签: json jsonschema