다음 데이터 + JSON 스키마 (동일한 데이터와 함께 JSON 스키마 생성기를 사용하여 생성됨)는 올바르게 유효성이 검사됩니다. 그러나 대신 여기에 valdation 오류가 나타납니다.JSON 스키마가 유효한 데이터 (validictory)에 대해 유효성을 검사하지 않습니다.
유효성 검사는 validictory 모듈을 기반으로합니다. 귀하의 유효성 검사 오류가 문제가 무엇인지를 알려줍니다
import json
import validictory
import jsonschema
data = [{u'text':
u'<h1>The quick brown fox</h1>',
u'title': u'hello world',
u'location': u'Berlin',
u'created': u'2013-03-12T12:13:14'}]
schema = {
"$schema": "http://json-schema.org/draft-03/schema",
"id": "http://jsonschema.net",
"required": False,
"type": "object" ,
"properties": {
"0" : {
"id": "http://jsonschema.net/0",
"required": False,
"type": "object" ,
"properties": {
"created" : {
"id": "http://jsonschema.net/0/created",
"required": False,
"type": "string"
},
"location" : {
"id": "http://jsonschema.net/0/location",
"required": False,
"type": "string"
},
"text" : {
"id": "http://jsonschema.net/0/text",
"required": False,
"type": "string"
},
"title" : {
"id": "http://jsonschema.net/0/title",
"required": False,
"type": "string"
}
}
}
}
}
print validictory.validate(data,schema)
validictory.validator.FieldValidationError: Value [{u'text': u'<h1>The quick brown fox</h1>', u'created': u'2013-03-12T12:13:14', u'location': u'Berlin', u'title': u'hello world'}] for field '_data' is not of type object
내가 쓴대로 : _same_ 데이터를 사용하여 스키마가 자동으로 생성되었습니다. – validator
OK. 그렇다면 그것이 잘못 생성됩니다. – Julian