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

320.3 ns

329.32 ns

1.15 us

5.8 ms

fastjsonschema

52.29 ns (x0.16)

134.43 ns (x0.4)

6.01 us (x5.22)

587.5 ms (x101.29)

jsonschema

289.97 ns (x0.9)

2.52 us (x7.65)

74.98 us (x65.2)

2.02 s (x348.27)

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

library

false

{"minimum": 10}

small

big

jsonschema-rs

402.35 ns

908.06 ns

9.54 us

5.9 ms

fastjsonschema

64.08 us (x159.26)

119.57 us (x131.67)

1.43 ms (x149.89)

599.84 ms (x101.66)

jsonschema

67.74 us (x168.36)

76.62 us (x84.37)

1.02 ms (x106.91)

2.11 s (x357.62)

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.2.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.2.0-cp38-cp38-manylinux2010_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

jsonschema_rs-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

jsonschema_rs-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

jsonschema_rs-0.2.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.2.0.tar.gz.

File metadata

  • Download URL: jsonschema_rs-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 c127023bed6c3628dc70aa5520add8492f8fba08907fbc6a7f84f6704396e683
MD5 64abfbfd968e9fb1b49182830efdf5d6
BLAKE2b-256 f484c9fed58ff6da059ed346c9a249b3ae88a2041291850ae90e72547eb9823a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonschema_rs-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 9.8 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.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c839c13afc9f4437ec6e52ba93407c5cfb93c4b94990be93d323c2f34f2c41ca
MD5 7ebae63c1838df96cc2dd38704631c48
BLAKE2b-256 74c7d11bf28f22a18d9956edfe48e8c4f2894c49212c544e5814d5853218fcb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonschema_rs-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 7.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.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 68a75f7137382c8863e1bdb80ac753da611cc40ec61bc9064d4d38f27065ee5f
MD5 66729dd66f72f19bd7ce0b4bb71d388b
BLAKE2b-256 fbb5752eba3b3c44dcf2233f269ca2054ebddf9261b6be2fa477b530d59837e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonschema_rs-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 5.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.2.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 527564d9eee38cf60c9d63272bbac4ce5eaf3ed07f7d4531cf27d5de57a8dd2a
MD5 2cfaeeb0fc00f2d4647037bae0576514
BLAKE2b-256 204a160ca8be9b34fcf510f56d3c128ea27dab3c36c09de97f5de8f864bbea5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonschema_rs-0.2.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.2.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5b674048cb1b0702a946bcb5b1d3ed09be93bbab037cc0343ee4ec6fde0630e0
MD5 6ba601b0531156ad5c5fb73fc91e65a6
BLAKE2b-256 67afa58606c289bed956d960e6dbccb0ca600690379c4a5167de8f9bdfb4a0d1

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