Library to apply JSON Patches according to RFC 6902
See source code for examples
- Website: https://github.com/stefankoegl/python-json-patch
- Repository: https://github.com/stefankoegl/python-json-patch.git
- Documentation: https://python-json-patch.readthedocs.org/
- PyPI: https://pypi.org/project/jsonpatch/
- CI: https://github.com/stefankoegl/python-json-patch/actions
- Coveralls: https://coveralls.io/github/stefankoegl/python-json-patch
jsonpatch ships type stubs (in the jsonpatch-stubs directory, as
jsonpatch.py is a single-file module), so type checkers such as mypy and
pyright work with it without further setup. JSON documents are typed as Any.
When changing the public API of jsonpatch.py, update
jsonpatch-stubs/__init__.pyi as well. These check that both agree, and that
typical usage in typetests/usage.py type-checks:
pip install mypy .
python -m mypy.stubtest --mypy-config-file pyproject.toml jsonpatch
cd typetests && mypy --config-file ../pyproject.toml usage.py
To run external tests (such as those from https://github.com/json-patch/json-patch-tests) use ext_tests.py
./ext_tests.py ../json-patch-tests/tests.json
Property-based tests using Hypothesis are in property_tests.py. Properties that the implementation does not satisfy yet are marked as expected failures.
pip install hypothesis
python property_tests.py
Set HYPOTHESIS_PROFILE=thorough to run many more examples.