Skip to main content

Fast JSON Schema validation for Python implemented in Rust

Project description

Build Version Python versions License

Fast JSON Schema validation for Python implemented in Rust.

Supported drafts:

  • Draft 7

  • Draft 6

  • Draft 4

There are some notable restrictions at the moment:

  • The underlying crate doesn’t support arbitrary precision integers yet, which may lead to SystemError when such value is used;

  • multipleOf keyword validation may produce false-negative results on some input. See #84 for more details

Installation

To install jsonschema-rs via pip run the following command:

pip install jsonschema-rs

Usage

To check if the input document is valid:

import jsonschema_rs

validator = jsonschema_rs.JSONSchema({"minimum": 42})
validator.is_valid(45)  # True

or:

import jsonschema_rs

validator = jsonschema_rs.JSONSchema({"minimum": 42})
validator.validate(41)  # raises ValidationError

NOTE. This library is in early development.

Performance

According to our benchmarks, jsonschema-rs is usually faster than existing alternatives in real-life scenarios.

However, for single-keyword or boolean schemas it might be slower than fastjsonschema or jsonschema on PyPy.

Schemas:

  • kubernetes-openapi is an Open API schema for Kubernetes which is ~3.15 MB JSON file.

  • small is taken from fastjsonschema benchmarks.

Compiled validators (when the input schema is compiled once and reused later). jsonschema-rs comes in two variants in the table below:

  • validate. This method raises ValidationError on errors or returns None on their absence.

  • `is_valid. A faster method that returns a boolean result whether the instance is valid.

Ratios are given against the validate variant.

library

false

{"minimum": 10}

small

kubernetes-openapi

jsonschema-rs[validate]

200.51 ns

203.30 ns

1.09 us

14.97 ms

jsonschema-rs[is_valid]

186.00 ns (x0.92)

186.79 ns (x0.91)

884.40 ns (x0.81)

13.94 ms (x0.93)

fastjsonschema[CPython]

58.57 ns (x0.29)

109.10 ns (x0.53)

4.21 us (x3.86)

91.79 ms (x6.13)

fastjsonschema[PyPy]

1.32 ns (x0.006)

33.39 ns (x0.16)

1.17 us (x1.07)

44.27 ms (x2.95)

jsonschema[CPython]

226.48 ns (x1.12)

1.88 us (x9.24)

58.14 us (x53.33)

1.07 s (x71.47)

jsonschema[PyPy]

41.18 ns (x0.20)

224.94 ns (x1.10)

25.97 us (x23.82)

663.30 ms (x44.30)

The bigger the input is the bigger is performance win. You can take a look at benchmarks in benches/bench.py.

Package versions:

  • jsonschema-rs - latest version from the repository

  • jsonschema - 3.2.0

  • fastjsonschema - 2.15.0

Measured with stable Rust 1.49, CPython 3.9.1 / PyPy3 7.3.3 on i8700K (12 cores), 32GB RAM, Arch Linux.

Python support

jsonschema-rs supports CPython 3.6, 3.7, 3.8 and 3.9.

License

The code in this project is licensed under MIT license. By contributing to jsonschema-rs, you agree that your contributions will be licensed under its MIT license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonschema_rs-0.6.1.tar.gz (56.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

jsonschema_rs-0.6.1-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

jsonschema_rs-0.6.1-cp39-cp39-manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.9

jsonschema_rs-0.6.1-cp39-cp39-macosx_10_15_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

jsonschema_rs-0.6.1-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8Windows x86-64

jsonschema_rs-0.6.1-cp38-cp38-manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8

jsonschema_rs-0.6.1-cp38-cp38-macosx_10_15_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

jsonschema_rs-0.6.1-cp37-cp37m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

jsonschema_rs-0.6.1-cp37-cp37m-manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.7m

jsonschema_rs-0.6.1-cp37-cp37m-macosx_10_15_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

jsonschema_rs-0.6.1-cp36-cp36m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.6mWindows x86-64

jsonschema_rs-0.6.1-cp36-cp36m-manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.6m

jsonschema_rs-0.6.1-cp36-cp36m-macosx_10_15_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6mmacOS 10.15+ x86-64

File details

Details for the file jsonschema_rs-0.6.1.tar.gz.

File metadata

  • Download URL: jsonschema_rs-0.6.1.tar.gz
  • Upload date:
  • Size: 56.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1.tar.gz
Algorithm Hash digest
SHA256 eb2c31fbdc110c06231d6893b6d572636c65e7b46e7f41189c8f52371ab7e598
MD5 3018292ffef049ae450b07cab3b84080
BLAKE2b-256 9310af42e8b3c2a6bcc7fe569ee924d6dd55ff7ccaaa8e89bab734dd48468ae3

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3de0945183093bf631f26388599f2ce8ecbce794607e1252fcf42de71fa6e9a1
MD5 405a7f94ce33ad8bacf7e26bb81b91a7
BLAKE2b-256 2b633f880444ab1330a415a8090cf03c5de2829415192e7d6b45cbf4298b8f8d

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c53c23be970613b3d9ec3329130d4ecab856f90353168a5e92393d632b413584
MD5 352cc12e17aaf47068aa771f394059e2
BLAKE2b-256 9740bde7b5b7e05a0daf3e5e3d9794d39e567369b3e184dd10e3c51291d2ace4

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c928eaa230766f403f295945a56de185be3c6f99e1d68ce65535ddd2b08d1a93
MD5 0c876aeaf2e49459fb93eb39b074410e
BLAKE2b-256 4b88f63f96d733a974c5f7ea52de936821f9c1d51285b9cd28aa785acdd79bea

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 accb80149173752aba84f6cae695657a04831ae8e68278aa0be5ba84853d0397
MD5 a6e4e17689f43dd7f0be81f892606ef5
BLAKE2b-256 a59e27026d70592228a78ee7aaccd566bd91bb720be0e1e6e36deef604b9ec5a

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 897d423a47796580843f536f864eba518be006f6585b370e5b2e3982506290c1
MD5 c3c4842e5c7d196a1414ef3583dca6ba
BLAKE2b-256 cbd686e5a6081ef596c971aa1d10ee995bec194c85092e797147061b7b28756e

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 4b6cf58e49d6931c855a351e496c2d3595c5133bddd24c5401b2a5c6c502c39c
MD5 bf2c26ffe9eb2e21f4c1e13ac0ab2e72
BLAKE2b-256 be6cafb8f5c952d63d970a9b4bc432b3a91c61e50916ca8b22f1ca65438b12d1

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 687150c795e9d12e59fb044cd4ff4a8c230660e14b3d2946f2f30397835b5057
MD5 1654c6422917e7ac7f9e58309d50a41e
BLAKE2b-256 13f062bccd3ad7811b7b5f784df749920d7e29c9519c7e977d52a0d00ba0fa9a

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d5ff112e38b856f163a8cb826325efa2b7eaa1bd5bd88de01fd11c7e7c2b417
MD5 93ba5bc31401848143d79fa18c2d9632
BLAKE2b-256 1ce34ab4bddff339a11a34214017087c88be465c43b208c6921eba1547e8ae27

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 929925a83f7cf2e27e482d6eee5a43d44867ab0efd8b55c2b2ce3d951fc08279
MD5 e562fb8dfd8a950ae130e70dc9bc933d
BLAKE2b-256 67bba9e460772f5a0492459b136a591d68c79ceb4b8a5f6ca1963647653b5c6e

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4540860347ab0ef8da53a322809afd44e5be95c23aae3e740cb5d417570da00d
MD5 7b3a3bbd47966b17e13dfd1e9b0a13e7
BLAKE2b-256 b792c6efce5657391c8088b5c53a0f33a9abf1e55823c95d1301a2741c2626e6

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55e021bb9845d7c4cc04b5001b75de5abc010412dd2e0bd69658bb561653d0b3
MD5 82d97f81402f86171d62a2e2964d9b10
BLAKE2b-256 8e06b8036003c9040088b48979a8684bdd27ff677fc532d4948449e5f41a7c41

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.6.1-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.6.1-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for jsonschema_rs-0.6.1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 30b8c220dafd42eec681d5fa9abd1266d5acd5ac398b3acf83f2e12d80a1a849
MD5 ce46457fd9cabf8f18a5e2462f0a0f84
BLAKE2b-256 88262223954eb5e598e33dc17066b8f778e794926b918a94af6925afa50ad689

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page