【发布时间】:2013-11-21 18:33:52
【问题描述】:
我正在尝试使用 ruby gem json-schema 验证一些 json 数据。
我有以下架构:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "User",
"description": "A User",
"type": "object",
"properties": {
"name": {
"description": "The user name",
"type": "string"
},
"e-mail": {
"description": "The user e-mail",
"type": "string"
}
},
"required": ["name", "e-mail"]
}
以及以下json数据:
{
"name": "John Doe",
"e-mail": "john@doe.com",
"username": "johndoe"
}
并且 JSON::Validator.validate 使用此数据作为输入,返回 true。
不应该是假的,因为用户名没有在架构上指定?
【问题讨论】:
标签: ruby json jsonschema