Fast JSON Schema validation for Python implemented in Rust
Project description
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.
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
Built Distributions
Hashes for jsonschema_rs-0.3.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51102df99cf39698876664d0a5dea26cac99194b6369eda532698da0b3781b09 |
|
MD5 | 26feb5f893bac13daa309d541ec6bf69 |
|
BLAKE2b-256 | 85e67737f51b2ca89284f4cd5297fa38ee2a435250bd2ea8039f5c19678705c6 |
Hashes for jsonschema_rs-0.3.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 315f2578b3209881fbedb9391d44a8e765649a6389508a7fe814216539a84f10 |
|
MD5 | 08da11cf2d27f987f7ae2930cf9666ec |
|
BLAKE2b-256 | 6be4845f1e954573ee682bdcf92ead0995ef9bcb4e33e8a835eb7948a98f9e81 |
Hashes for jsonschema_rs-0.3.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 734e854e5e04fce0ba7515cb4cafb30342d16761e0854ae2decdde657e5cb038 |
|
MD5 | 3e92d6ce6885f93cfd2423e49f2bb489 |
|
BLAKE2b-256 | 78bc8cc24e5a06229dfb1fd2399543095fefc5f7dba5853e927a7d387d76d7f8 |
Hashes for jsonschema_rs-0.3.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a830cef1a3a5fabc7f8e0697e26341e0f5cd8015da3bf274c24f7791bb8cbd4a |
|
MD5 | 320be57b40b98a381da073f7b2cd1d50 |
|
BLAKE2b-256 | 1b5cbb97b6bb29f6c83aafef27d6dcb0979f1976f0ae95de59f134eab37e9743 |
Hashes for jsonschema_rs-0.3.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11835df5e57dcb375a0d7a20d91472f3310a589ae22788632170aa36a717b2f2 |
|
MD5 | 9d13a08c21b8fc035abc9d361d38d02a |
|
BLAKE2b-256 | 1dd3962b4cce62470d6f17761cef3de9c3b1cd9438ee0a628d2bedb75e0b682e |
Hashes for jsonschema_rs-0.3.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f07c2578335149e36fba5b0d8a91cc998ec83f100fe2840eec72dba67bd704d |
|
MD5 | 794f58b7314b0a9d11f90798ab5c4ccf |
|
BLAKE2b-256 | a15683de54463dd4b1973de6e734381120d9b35d9b097bdc144d8dc0ab09eccd |
Hashes for jsonschema_rs-0.3.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62134aa6ca49b859eb340873bab9e358e8716eac7d7cabc7053a42b3fae80ce6 |
|
MD5 | 66f017227cdc6c933ca6405837fba6eb |
|
BLAKE2b-256 | cf777e79cb112daa17777f851a9c75c2b67c3accd1d7c1eed7ec425118ece2a1 |
Hashes for jsonschema_rs-0.3.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef023902126480e20c2fdf91fc7f47c7714b769b5d11130a3f34d8d2a82f9cca |
|
MD5 | 232aad8078040e3eeb8316b25be35619 |
|
BLAKE2b-256 | 44ea1ee72df08d9f5308ce58cb04de938b9ed38525c48dc0af50c083dd7c2eea |
Hashes for jsonschema_rs-0.3.2-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec1d7d4662d42bc5f41eef1d4550e1ff927b3e4e06cc83653820b333220b0759 |
|
MD5 | 414627cae4d130fdfcc32c06c286ca1b |
|
BLAKE2b-256 | 17fc7c4cb40280a504353d077f0099eefe7dbe126a5efd692c934fbe84e9cb3b |
Hashes for jsonschema_rs-0.3.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a9e4b2f8544e538feeb3eaf32e2de611d573f0979ede0f42a3d00915466b407 |
|
MD5 | 3b789943b319e7ae0ba02c5202bceb84 |
|
BLAKE2b-256 | 37435905314d548d94c292932f1cbb5b12da80bc6c071be7d8d3b602b4228aa2 |
Hashes for jsonschema_rs-0.3.2-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adc4ec3eb3defd1782f753f78d99ffb1bccb24e9fc3a33e14a850b4d34a6e911 |
|
MD5 | 02770395cde20f9b681127e66c789b91 |
|
BLAKE2b-256 | d54836efc87ea1e25cb6f58be3e532724a822cb92b94f62b862ee81008dad0b0 |
Hashes for jsonschema_rs-0.3.2-cp35-cp35m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa567101072f7d086c67e0bd1d41e11e3e6ba5e95729b301e54a6986d35f94b |
|
MD5 | e070de70c26a01fbcb8bb195bc9cc1ce |
|
BLAKE2b-256 | c3f841260cf3e61e5aecf320c88208b4b97ba17de8395e596eb74c63eeafbd85 |