python - JSON schema validation with arbitrary keys -
I am using validation to validate attached JSON data and schemas. Working till now
However the data dictionary may contain arbitrary string keys (other than 'BP'). The key 'BP' in the schema is worked hard here ... This can be a string from the given list (the number of strings). How do I add definition to "first level" of dict? Import json import valid data = {'bp': [{'category': 'bp', 'created': '2013-03-08T09: 14: 48.148000', 'day': '2013-03-11T00: 00 : 00 ',' Id ':' DC 049CD-D1991-4E3-93-A646438A239712 ',' Unit ':' MMHG ',' Value ': 147.0, '' Value '': 43.0}] {"type": "object", "property": {"bp": {"type": "array", "required": wrong, "item": {"type": {"Type": "string", "default": "bp", "required": wrong}, "created": {"type": "string": "object", "required" , "Default": "2013-03-08T09: 14: 48.148000", "required": false}, "days": {"type": "st "", "Default": "2013-03-11T00: 00: 00", "required": incorrect, "id": {"type": "string", "default": "dc049c0e-d19a-4e3e-93ea "", "Value": {"type": "number"), "unit": "type": "string", "default": "mmHg", "required" False "}}}}}} is valid.", "Default": 43, "required": false}, "value": {"type": "number", "default": 147, "expected"). Valid (data, schema)
It depends on exactly what you do Are trying to
If you want the same specification, but for a range of properties, the definition: "" "object", "object", "property": {"bp": {"$ ref": {"$ Ref": "# / definitions / categoryList"}}, "# / Definitions / Category List"}, "Foo" ": {" $ Ref ":" # / Definitions / Category "}," Bar " "Definitions": {"categoryList": {...}}}
If you want to any assets to follow that schema, Then you can use these qualities A category of (corresponds to a pattern) - for example, anything less-ke: If you want to limit the number of properties that can be defined, you can use" maxProperties "(standard v4 ): P. s. In standard v4, there is an array of "required". In fact, in v3, the default for "required" is additionalProperties
{"type": "object", "additionalProperties": {...}} < / Pre>
{"type": "object", "patternProperties": {"^ [az ] + $ ": {...}}}
{"type": "object", "additional properties": {...}, "maximum properties": 1}
false , so your example is not needed
Comments
Post a Comment