【发布时间】:2020-12-30 15:10:31
【问题描述】:
提前感谢您的帮助。这是我糟糕的一天。
我有以下 json,我正在尝试找出它的架构。不幸的是,我被困在一个没有任何错误迹象的地方。
请告知解决方法
{
"tables_not_to_mask": ["Table_1"],
"tables_to_mask":{
"Table_2": [
{
"column": "BinLogFilename",
"masking_type": "replace_logfilename"
},
{
"column": "ServerId",
"masking_type": "replace_server_id"
}
],
"Table_3": [
{
"column": "BinLogFilename",
"masking_type": "replace_logfilename"
},
{
"column": "ServerId",
"masking_type": "replace_server_id"
}
]
}
}
Table_1、Table_2、.. 是动态添加的。我已经创建了应该在下面验证 JSON 输入的架构,
- tables_not_to_mask 和 tables_to_mask 是必需的。
- tables_to_mask 可以有零个或多个表
- 如果tables_to_mask 中有表,它可以定义零到多列和masking_type。
- column 和 masking_type 是强制性的,没有一个是单一的。
我为它创建了架构,不幸的是,如果我删除列或 masking_type,架构不会引发任何错误。
{
"title": "Schema title",
"description": "Description of the schema",
"type": "object",
"properties": {
"tables_not_to_mask": {
"type": "array",
"minItems": 0,
"items": {"type": "string"}
},
"tables_to_mask": {
"type": "object",
"patternProperties": {
".*": {
"type": "array",
"minItems": 0,
"properties": {
"column": {"type": "string"},
"masking_type": {"type": "string"}
},
"required": [
"masking_type",
"column"
]
}
}
}
},
"required": [
"tables_not_to_mask",
"tables_to_mask"
]
}
【问题讨论】:
标签: json jsonschema json-schema-validator