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

NOTE. This library is in early development and not yet provide a way to show validation errors (even though it is implemented in the underlying Rust crate).

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.

Compiled validators (when the input schema is compiled once and reused later)

library

false

{"minimum": 10}

small

big

jsonschema-rs

273.01 ns

263.29 ns

904.38 ns

4.96 ms

fastjsonschema

49.77 ns (x0.18)

130.21 ns (x0.49)

5.7 us (x6.31)

575.66 ms (x115.84)

jsonschema

278.27 ns (x1.01)

2.41 us (x9.15)

75.27 us (x83.23)

1.83 s (x368.47)

Validators are not compiled (jsonschema) or compiled on every validation:

library

false

{"minimum": 10}

small

big

jsonschema-rs

349.74 ns

465.67 ns

6.97 us

5.15 ms

fastjsonschema

62.46 us (x178.59)

112.64 us (x241.9)

1.33 ms (x191.67)

574.5 ms (x111.55)

jsonschema

64.57 us (x184.64)

74.2 us (x159.34)

951.38 us (x136.37)

1.85 s (x360.38)

The bigger the input is the bigger is performance win.

In the examples below, big and small schemas refer to more realistic schemas and input instances. You can take a look at benchmarks in benches/bench.py. Ratios are given against jsonschema-rs.

Python support

jsonschema-rs supports Python 3.5, 3.6, 3.7 and 3.8.

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.3.0.tar.gz (44.0 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.3.0-cp38-cp38-manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

jsonschema_rs-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

jsonschema_rs-0.3.0-cp36-cp36m-manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

jsonschema_rs-0.3.0-cp35-cp35m-manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

File details

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

File metadata

  • Download URL: jsonschema_rs-0.3.0.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for jsonschema_rs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5c36d612d9d1f9c3fe5e31b68991d94afe243cdf32beed87bf3ebcef916dc0ce
MD5 692ce0408a0737b7eb26842a83533705
BLAKE2b-256 da67d07e8681235b3062d6a4ad40c8a4daf110ec19fd10e9d4fe096c18c9a3d3

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.3.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.3.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for jsonschema_rs-0.3.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7c1e165197a0c05a745268b0219130677635e4fcdb5c615c97ceb434613c906a
MD5 97de028d8763ad77550ca998e4e81276
BLAKE2b-256 a5f02721f0e3689ea736e5e0c09e57dde3afa33fa5e971171921bf8377a7dbdb

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for jsonschema_rs-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f4ab2f7c3a6b466665585a1656a6b3c657825bcbb78826e6107ebbc82d56a19a
MD5 dffc6c209c9e91795fce1d6c25a29a97
BLAKE2b-256 3d964e92939e99442128d911788f26eadb6b1d0e73d9ab7c51af473e0a18a838

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.3.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.3.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for jsonschema_rs-0.3.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a146afaa32bf2528f23ec2c88565a9cf60afd6826b9da39b1dcb0417c6eeb132
MD5 7e29c976c7123a709034e1dcf7bd2ee5
BLAKE2b-256 2b6dcc609d7bbe8e9ba60add15b737ac235f4b4e8e7c1d159999f6c434f5d7c9

See more details on using hashes here.

File details

Details for the file jsonschema_rs-0.3.0-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: jsonschema_rs-0.3.0-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for jsonschema_rs-0.3.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 6ac545bda8016a7e04f06eba381c4117a857adac605b04b09484cd94995fc4ec
MD5 d180459339ee9b63fbf3ed36c5186bd8
BLAKE2b-256 b7e47e3869e3bd95299b1d41a6119760a0fd955725985e6cf04c3f6efb666931

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