【发布时间】:2012-09-22 19:26:51
【问题描述】:
我正在尝试使用 (https://github.com/fge/json-schema-validator) 模式验证器验证我的 JSON。
您建议使用杰克逊模式生成来生成 JSON 模式还是有更好的方法?
我有一个名为 (Location) 的对象,其中包含对象列表 (BaseObject)。 我为这样的位置创建了一个模式,其中包含 BaseObject 的 $ref。但验证失败并显示错误消息 - ["": domain: validation;关键字:属性;消息:未找到所需的属性;缺失:["id","refName"];必需:["id","refName"]]
我使用 refs 的方式有错误吗?
Location.json - 架构
{
"type":"object",
"properties":{
"locationType":{
"type":"string"
},
"mapsRefs":{
"$ref": "file://localhost/c:/baseobject.json"
}
}
}
}
baseobject.json - 架构
{
"type":"object",
"properties":{
"refName":{
"type":"string",
"required":true
},
"id":{
"type":"integer",
"required":true
},
"refs":{
"type":"array",
"required":false,
"items":{
"type":"string"
}
}
}
}
【问题讨论】:
-
在 Location.json 中是一个太多的右括号
标签: java json jsonschema