Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An implementation of the JSON Schema specification for Python

License

NotificationsYou must be signed in to change notification settings

python-jsonschema/jsonschema

Repository files navigation

PyPI versionSupported Python versionsBuild statusReadTheDocs statuspre-commit.ci statusZenodo DOI

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.

Features

Installation

jsonschema is available onPyPI. You can install usingpip:

$ pip install jsonschema

Extras

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.

Running the Test Suite

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.

Benchmarks

jsonschema's benchmarks make use ofpyperf.Running them can be done via:

$ nox -s perf

Community

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.

About

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.


[8]ページ先頭

©2009-2025 Movatter.jp