【发布时间】:2021-03-21 22:26:40
【问题描述】:
我开发了这个架构
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["users"],
"properties": {
"users":{
"type":"object",
"additionalProperties": false,
"patternProperties": {
"^APP-[A-Z_-]+$": {
"$ref": "#/definitions/user"
},
"^[A-Za-z0-9\\._%\\+-]+@[A-Za-z0-9\\.-]+\\.[A-Za-z]{2,6}$": {
"$ref": "#/definitions/user"
}
}
}
},
"definitions": {
"user":{
"type":"object",
"additionalProperties": false,
"properties": {
"full_name": {"type": "string", "pattern": "^[^\\s]+(\\s+[^\\s]+)*$"},
"email": {"type": "string", "format": "email"}
}
}
}
}
满足以下文件
{
"users": {
"APP-TEST": {
"full_name": "test",
"email": "test@local.com"
},
"user1@local.com": {
"full_name": "test",
"email": "test@local.com"
},
"user2@local.com": {
"full_name": "test",
"email": "test@local.com"
}
}
}
但我不知道如何验证 JSON 文档,例如说我想要一个“APP-”键和许多“email-pattern-users”键。
【问题讨论】:
标签: python json jsonschema