JsonPatchX is a typed JSON Patch toolkit for building governed PATCH APIs in Python.
It scales from simple patching to highly controlled API contracts:
- Plain JSON patching
- FastAPI PATCH endpoints
- Expressive, governed PATCH APIs with typed pointers, custom operations, route allow-lists, JSONPath pointers, and more.
Install from PyPI:
pip install jsonpatchx[fastapi]Basic patch application:
from jsonpatchx import JsonPatch
doc = {"name": "Ada", "roles": ["engineer"]}
patch = JsonPatch.from_string(
"""
[
{"op": "replace", "path": "/name", "value": "Ada Lovelace"},
{"op": "add", "path": "/roles/-", "value": "maintainer"}
]
"""
)
updated = patch.apply(doc)For practical end-to-end examples:
- FastAPI demos: examples/README.md
- Operation recipes: examples/recipes.py
- Error payload shapes: docs/demo-error-shapes.md
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. For detailed contributing guidelines, please see CONTRIBUTING.md
Distributed under the MIT License. See LICENSE for more information.
Anglea Liss - chamsester@gmail.com
Project Link: https://github.com/angela-tarantula/jsonpatchx
Thanks to these foundational projects:
And to these excellent alternatives: