-
Notifications
You must be signed in to change notification settings - Fork 18
Quickstart
SA edited this page Jan 10, 2020
·
1 revision
The fastest way to validate a schema against json is to use the validate()
function provided in json_schema_validator.shortcuts
.
To import 'shortcuts' use:
from json_schema_validator.shortcuts import *
The function validate()
provided by 'shortcuts' takes two positional arguments, schema text
and json text
. Simply pass in a valid json schema as raw string and then the json text to validate as a raw string:
from json_schema_validator.shortcuts import *
schema = open("a_schema.json", 'r')
json = open("some_json.json", 'r')
validate(schema.read(), json.read())
validate()
will first test the schema parameter against it's schema specification, followed by the json parameter against the schema parameter. Problems with...
- json syntax in either schema or json subject documents
- adherence to schema specifications
- adherence of your subject json to your provided schema
...will throw exceptions, otherwise this function will return True