谢谢你提前帮忙。这是我糟糕的一天。
我有下面的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输入,
我为它创建了模式,不幸的是,如果我删除列或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"
]
}发布于 2020-12-31 07:32:24
最后,我得到了答案。谢谢你调查。
{
"$schema": "https://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"tables_not_to_mask":
{"$ref": "#/definitions/tables_not_to_mask_type"},
"tables_to_mask":
{"$ref": "#/definitions/tables_to_mask_type"}
},
"required": [
"tables_not_to_mask",
"tables_to_mask"
],
"definitions": {
"tables_not_to_mask_type": {
"type": "array",
"minItems": 0,
"items": {"type": "string"}
},
"tables_to_mask_type": {
"type": "object",
"patternProperties": {
".*": {"$ref": "#/definitions/tables_type"}
}
},
"tables_type": {
"type": "array",
"minItems": 0,
"items": {
"type": "object",
"properties": {
"column": {"type": "string"},
"masking_type": {"type": "string"}
},
"required": [
"masking_type",
"column"
]
}
}
}
}https://stackoverflow.com/questions/65509146
复制相似问题