【发布时间】:2016-10-04 03:10:30
【问题描述】:
我是 JSON Schema Validator 的新手,但我认为它非常强大。但是,我无法验证一个 JSON。
这是我的架构
{
title: "Example Schema",
type: "object",
properties: {
original_image:{
type: "object",
properties: {
temp_id: {type: "string"},
url: {type: "string"},
scale:{
type: "object",
properties:{
new_width: {type: "number"},
new_height: {type: "number"}
},
required:["new_width","new_height"]
}
},
required:["url","temp_id","scale"]
}
},
required:["image"]
}
这是实际的 JSON:
{
"original_image": {
"temp_id": "this is my id",
"scale": {
"new_width": null,
"new_height": 329
}
}
}
因此,您可以看到“original_image”中的“url”属性不存在,但验证返回 true!而且,对于“new_width”,我将值设置为 null... 并再次通过验证,所以我不知道自己做错了什么。
【问题讨论】:
标签: node.js jsonschema json-schema-validator