【发布时间】:2017-01-30 15:19:51
【问题描述】:
下面的 Json 模式和 Json 文档都是有效的 json。 只是我无法获得与 json 架构相关的有效 Json 文档。
我收到错误消息:不应该有其他属性
Json 架构
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Movies Schema",
"description": "Movies schema containing ratings and genres",
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "number"
},
"title": {
"type": "string"
},
"release_date": {
"type": "string"
},
"video": {
"type": "string"
},
"IMDBURL": {
"type": "string"
},
"genres": {
"type": "array"
}
},
"required": [
"id",
"title",
"release_date",
"video",
"IMDBURL",
"genres"
]
},
"users": {
"type": "object",
"additionalProperties": false,
"properties": {
"user_id": {
"type": "number"
},
"ratings": {
"type": "number"
},
"timestamps": {
"type": "string"
}
},
"required": [
"user_id",
"ratings",
"timestamps"
]
}
}
JSON 文档
[
{
"id": 1,
"title": "Kung Fu Panda",
"release_date": "01-01-2001",
"video": "",
"IMDBURL": "link.com",
"genres": [
"abc",
"def"
],
"users": {
"user_id": 2,
"ratings": 3,
"timestamps": "2342478"
}
}
]
【问题讨论】:
标签: json jsonschema json-schema-validator