Skip to content

Description:

  • jsonschema is an implementation of the JSON Schema specification for Python.

Resources:

Source and license:

Validate a schema

from jsonschema import validate
# A sample schema, like what we'd get from json.load()
schema = {
"type" : "object",
"properties" : {
"price" : {"type" : "number"},
"name" : {"type" : "string"},
},
}
# If no exception is raised by validate(), the instance is valid.
# This is valid
validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema)
# This is invalid
validate(
instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema,
)

ganymede is made by Eugo