我需要使用
我已经通过使用gojsonschema库来实现它,这是一个非常直接的库。
然而,我现在面临的问题是,我已经得到了具有对另一个模式的依赖关系的模式,并且没有找到加载所有所需模式的方法。因此,我的验证总是失败。
这是我的主要模式:
Golang
验证多个JSON
文件是否符合模式。我已经通过使用gojsonschema库来实现它,这是一个非常直接的库。
然而,我现在面临的问题是,我已经得到了具有对另一个模式的依赖关系的模式,并且没有找到加载所有所需模式的方法。因此,我的验证总是失败。
这是我的主要模式:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/List",
"definitions": {
"List": {
"type": "array",
"items": {
"$ref": "#/definitions/Item"
}
},
"Item": {
"description": "An item ....",
"type": "object",
"additionalProperties": false,
"properties": {
"property01": {
"description": "The property01 code.",
"$ref": "./CommonTypes.json#/definitions/Type01Definition"
}
},
"required": [
"property01"
]
}
}
}
还有一个包含常见类型的:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"Type01Definition": {
"description": "The definition for the type 01",
"type": "string",
"pattern": "^[A-Z0-9]{3}$"
}
}
}
有没有办法使用该库加载多个模式?或者是否有其他Golang
库可以实现这一点?