JSON Schema compatibility checker for evolving schemas
Project description
jsoncompat
Python bindings for checking compatibility of evolving JSON Schemas and generating example values.
Installation
Install from PyPI:
pip install jsoncompat==0.3.1
Quick start
import jsoncompat as jsc
old_schema = '{"type": "string"}'
new_schema = '{"type": "number"}'
is_compatible = jsc.check_compat(old_schema, new_schema, jsc.Role.BOTH)
print(is_compatible)
# Generate example values for a schema
generator = jsc.generator_for(old_schema)
example = generator.generate_value(depth=5)
print(example)
API
check_compat(old_schema_json: str, new_schema_json: str, role: str = "both") -> boolrolemust be"serializer","deserializer", or"both".- Raises
ValueErrorfor invalid schemas or hard unsupported compatibility features such as non-integralnumber.multipleOf.
generator_for(schema_json: str) -> Generator- Parses the schema once and returns a reusable generator.
Generator.generate_value(depth: int = 5) -> strreturns a JSON string for one generated value accepted by the schema.- Raises
ValueErrorwhen the schema is invalid, known to be unsatisfiable, or generation exhausts its retry budget.
validator_for(schema_json: str) -> Validator- Parses the schema once and returns a reusable validator.
Validator.is_valid_json(instance_json: str) -> boolvalidates JSON strings against the parsed schema.Validator.is_valid_value(instance: JsonValue) -> boolvalidates Python JSON-compatible values:None,bool, finiteint/float,str,list,tuple, anddict[str, ...].
generate_value(schema_json: str, depth: int = 5) -> str- Deprecated. Use
generator_for(schema_json).generate_value(depth)instead.
- Deprecated. Use
is_valid(schema_json: str, instance_json: str) -> bool- Deprecated. Use
validator_for(schema_json).is_valid_json(instance_json)instead.
- Deprecated. Use
jsoncompat.codegen.dataclassesruntime helpers for generated dataclass modelsRole.SERIALIZER,Role.DESERIALIZER, andRole.BOTHare string constants accepted bycheck_compat.
Schemas are passed as JSON strings. check_compat returns a boolean verdict and raises ValueError for invalid JSON, invalid schemas, or hard unsupported compatibility cases.
More detail
Benchmarks
Run the generated dataclass runtime microbenchmark from the repository root:
env -u VIRTUAL_ENV uv run --project pybindings python pybindings/bench_dataclasses_runtime.py
License
MIT License. See:
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 Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f822fa3c983bf6354a08e5357ad629451a4acf8c9e32ff87f6fe5646157dcb1d
|
|
| MD5 |
22d6d6e38467ae0bc3226087056e765e
|
|
| BLAKE2b-256 |
319d597f17969f710c50c4407ea2997820dac0c06c49b743450a07ba03a3455d
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-win32.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-win32.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.13, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cec12a81ab11ee8553666468b4e83029f4822ffeefd7073330517ae18936e75f
|
|
| MD5 |
a55a4ae80ff002ad7c92d5237d0b59c5
|
|
| BLAKE2b-256 |
dd3ff5adba947d609e3a1e6171bc6e0574739fc859b377bf548239ebc7f72d0d
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33d83075308ab7ea66021055bcb4a27c9f93de54168d2725b96f64131325de8f
|
|
| MD5 |
f478a39d3233675c3c3dccc58175325d
|
|
| BLAKE2b-256 |
e6ad00fda63964ce68f6806f020a7eb0c95fdd5bf75cd9b6423b49b214d79797
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c1a350ff6e3cb9b5af44c556f0ff71e3c676fe22e21f4f21aef3033d63813eb
|
|
| MD5 |
fa25a4f47b76def8a65917de8532081c
|
|
| BLAKE2b-256 |
b89b28ba84b9b27f23756a516d343cf38aa66ba981e8886273c2fe6f572d9255
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216f6b9b10fa26e93875a7307c0c624cc54e40c3a1502f140e8ad4cecbbe3522
|
|
| MD5 |
3b443582b804ad1f70053821b2880397
|
|
| BLAKE2b-256 |
d7b99058b9da7a5355cc5ae4ff5d7d5f954abbd8ed0d69b9de244c5215292d04
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c77275abb1da70b978cabdb64dcd821bd34efb38afffc5085ab9f1998362a79
|
|
| MD5 |
20eb3709de04adbf22fe0ae48279039d
|
|
| BLAKE2b-256 |
8a2580ff5777fab283568bed5dc72d6201d457dcb52deffa197eed393225a460
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7062798f080f662f7d875ad90a04fa03cb0eac08f0fe8013b4b10915aeac136
|
|
| MD5 |
2c6d1d018c4d2c9a5441ee0969ca989d
|
|
| BLAKE2b-256 |
ce5937cc8396cb6429d692798136a9256bedeb98c992c51fd96d7ea87a67d829
|
File details
Details for the file jsoncompat-0.4.1-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f326f0c9376c26eb64de309997c62c6c174997b9305f57203f401d437e2e91e
|
|
| MD5 |
723b432c2b12489ead1c89179cea1d03
|
|
| BLAKE2b-256 |
912f629bd9e2fb6e24dcc7a32fbd29860d67e919ae9561c560fbe2a657762b32
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39043d1772215349b3bcd9a4b8a5e9d62d766b7a6d9fc1a5753dc3065bbf864d
|
|
| MD5 |
56b90507edb26eaf2e55a0024a819027
|
|
| BLAKE2b-256 |
62d3372e139da93d20b6ee9135d1aa370d64caa00192996ead5f5feb66a10e19
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-win32.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-win32.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13a1516908130247ca97074a5c9f190fad90ca64d0953b58b09eecf3d82a2a5e
|
|
| MD5 |
9247d53b3a24d14bb9197fff1f7fe1cc
|
|
| BLAKE2b-256 |
5049fa99d39cf2ee30a038432870fe2497d07497cec1027d2bc84e871965acf9
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a924d9f8497458e6a688a619b5d18d8a5fd7f2e0f4f5b7a9d6cf0ef258f3d3a1
|
|
| MD5 |
0dc386387e20a706e471e4f8d0ded5bf
|
|
| BLAKE2b-256 |
3be3bef006da7b042fb3520a9f45f209f3881a42f78c30e9a429d9832be45e30
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81d76bad843037cbcb573e0ac7ee71f6b8195464d62a8b7052ce395c36379c3f
|
|
| MD5 |
e315acedfe4cb7021caff67146a8dc86
|
|
| BLAKE2b-256 |
d458943009bb677d71583befa38ddd224a7ca8b39d294ddc78c51d9e2811d553
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f88811cdd72b03bb4432d237c7fe020258b08c35137c7b5fba4441096b3dfee
|
|
| MD5 |
a246d5fdd11cb53d059bbba9568606af
|
|
| BLAKE2b-256 |
a5f8576b64383556588f42a4e47a3f0a61b1d7d4884f740338438dd2e48b43a3
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47475e63c9fc83ee8c165513157b16b15ed34a7bc199b421e31eb0bf27fd6aff
|
|
| MD5 |
417524cc330588eae4ac86827a61eaae
|
|
| BLAKE2b-256 |
ddcab86521fdaf31b9deb478ee1250898fad8efb45dcb390c937df7f3a97f9c3
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1820fbb7d31b3e21e6801a2c651444cc789393014fbba88d9613c21595068e52
|
|
| MD5 |
8e96b38b2b8ccd33a65db5f70698e2b5
|
|
| BLAKE2b-256 |
063d52411a664680faae74b575c59b5a564f9ee4c4474305732f58d43c2e669b
|
File details
Details for the file jsoncompat-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: jsoncompat-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9c92aa33ce6f30479336362d63ee632cb83c2fdb9e849885cd6de3263ca1d90
|
|
| MD5 |
b9eec69ccf90bfe7983cf714137aea86
|
|
| BLAKE2b-256 |
7f80dcfe841fc759be169b24c2be9be141469c4cb7d90ddfaee143a6fcc0725a
|