2
小さなチャンクos jsonスキーマを記述しましたが、python jsonschemaを使用して検証エラーが発生しました。ここで'type' jsonスキーマの検証に失敗しました
は私のスキーマです:ここでは
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"output": {
"type": "object",
"properties": {
"Type": {
"type": "object",
"properties": {
"Type": {
"type": "string"
},
"Value": {
"type": "string"
},
"Default": {
"type": "string"
},
"Description": {
"type": "string"
},
"Options": {
"type": "array"
}
},
"required": [
"Type",
"Value",
"Default",
"Description",
"Options"
]
},
"Inverted": {
"type": "object",
"properties": {
"Type": {
"type": "string"
},
"Value": {
"type": "bool"
},
"Default": {
"type": "bool"
},
"Description": {
"type": "string"
}
},
"required": [
"Type",
"Value",
"Default",
"Description"
]
},
"Pulse Width": {
"type": "object",
"properties": {
"Type": {
"type": "string"
},
"Value": {
"type": "number"
},
"Default": {
"type": "number"
},
"Description": {
"type": "string"
}
},
"required": [
"Type",
"Value",
"Default",
"Description"
]
}
},
"required": [
"Type",
"Inverted",
"Pulse Width"
]
}
}
}
は、私が受けてるのエラーです:
Failed validating u'type' in schema
私は自分のスキーマを検証しようとしています:
schema = ""
with open(jsonSchemaFilePath, 'r') as schema_file:
schema = schema_file.read()
try:
Draft4Validator.check_schema(schema)
except SchemaError as schemaError:
print schemaError
何私が書いたスキーマに間違っているのですか? Typeという名前のプロパティを持つことは許されませんか?
:ここ
は、私の解決策でした。私は自分のJSONを自分のシェルにロードしようとしましたが、うまくいきました。 'check_schema'はjsonオブジェクトを期待していますか? –
'check_schema'が' dic'を探していた – visc
嬉しいです。あなたはあなたの答えを正しいものとしてマークしてください! –