我不知道如何正确地设置一个超模式来使用json-schema-validator。我使用的是json-schema-validator的java版本,版本是2.2.5。
我的方案是:
{
"$schema": "http://json-schema.org/draftv4/hyper-schema#",
"title": "User object",
"description": "A user representation",
"type": "object",
"properties": {
"email": {
"description": "The user's email address",
"format":"email",
"maxLength": 255
},
"picture": {
"description": "The user's picture",
"type": "string",
"media": {
"binaryEncoding": "base64",
"type": "image/png"
}
}
}
}我的json对象是:
{"email":"k@w.de",
"picture":null}现在,当我将模式加载到JsonSchemaFactory中并打算开始验证时,我收到以下警告:
warning: the following keywords are unknown and will be ignored: [media]
level: "warning"
schema: {"loadingURI":"#","pointer":"/properties/picture"}
domain: "syntax"
ignored: ["media"]除了$schema字段之外,是否还有其他东西需要配置以使用超模式?
发布于 2014-11-03 02:07:06
这是因为您的$schema是错误的!
应该是http://json-schema.org/draft-04/hyper-schema#。有关常见URI的列表,请参阅section 6 of the core specification。
https://stackoverflow.com/questions/26688131
复制相似问题