Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork593
An implementation of the JSON Schema specification for Python
License
python-jsonschema/jsonschema
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
jsonschema
is an implementation of theJSON Schema specification for Python.
>>>fromjsonschemaimportvalidate>>># 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.>>>validate(instance={"name" :"Eggs","price" :34.99},schema=schema)>>>validate(...instance={"name" :"Eggs","price" :"Invalid"},schema=schema,... )# doctest: +IGNORE_EXCEPTION_DETAILTraceback (mostrecentcalllast): ...ValidationError:'Invalid'isnotoftype'number'
It can also be used from the command line by installingcheck-jsonschema.
- Full support forDraft 2020-12,Draft 2019-09,Draft 7,Draft 6,Draft 4 andDraft 3
- Lazy validation that can iteratively reportall validation errors.
- Programmatic querying of which properties or items failed validation.
jsonschema
is available onPyPI. You can install usingpip:
$ pip install jsonschema
Two extras are available when installing the package, both currently related toformat
validation:
format
format-nongpl
They can be used when installing in order to include additional dependencies, e.g.:
$ pip install jsonschema'[format]'
Be aware that the mere presence of these dependencies – or even the specification offormat
checks in a schema – donot activate format checks (as per the specification).Please read theformat validation documentation for further details.
If you havenox
installed (perhaps viapipx install nox
or your package manager), runningnox
in the directory of your source checkout will runjsonschema
's test suite on all of the versions of Pythonjsonschema
supports.If you don't have all of the versions thatjsonschema
is tested under, you'll likely want to run usingnox
's--no-error-on-missing-interpreters
option.
Of course you're also free to just run the tests on a single version with your favorite test runner.The tests live in thejsonschema.tests
package.
jsonschema
's benchmarks make use ofpyperf.Running them can be done via:
$ nox -s perf
The JSON Schema specification hasa Slack, with aninvite link on its home page.Many folks knowledgeable on authoring schemas can be found there.
Otherwise, opening aGitHub discussion or asking questions on Stack Overflow are other means of getting help if you're stuck.
I'm Julian Berman.
jsonschema
is onGitHub.
Get in touch, via GitHub or otherwise, if you've got something to contribute, it'd be most welcome!
If you feel overwhelmingly grateful, you can alsosponsor me.
And for companies who appreciatejsonschema
and its continued support and growth,jsonschema
is also now supportable viaTideLift.
About
An implementation of the JSON Schema specification for Python
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.