GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - stefankoegl/python-json-patch: Applying JSON Patches in Python

BranchesTags
Open more actions menu

Latest commit

 

History

567 Commits
567 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
doc
doc
 
 
jsonpatch-stubs
jsonpatch-stubs
 
 
typetests
typetests
 
 
.coveragerc
.coveragerc
 
 
.flake8
.flake8
 
 
.gitignore
.gitignore
 
 
.readthedocs.yaml
.readthedocs.yaml
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
README.md
README.md
 
 
RELEASING.md
RELEASING.md
 
 
ext_tests.py
ext_tests.py
 
 
jsonpatch.py
jsonpatch.py
 
 
jsonpatch_cli.py
jsonpatch_cli.py
 
 
makefile
makefile
 
 
property_tests.py
property_tests.py
 
 
pyproject.toml
pyproject.toml
 
 
pytest.ini
pytest.ini
 
 
requirements-dev.txt
requirements-dev.txt
 
 
requirements.txt
requirements.txt
 
 
setup.py
setup.py
 
 
tests.js
tests.js
 
 
tests.py
tests.py
 
 

Repository files navigation

python-json-patch

PyPI version Supported Python versions Build Status Coverage Status

Applying JSON Patches in Python

Library to apply JSON Patches according to RFC 6902

See the tutorial 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.io/
  • PyPI: https://pypi.org/project/jsonpatch/
  • CI: https://github.com/stefankoegl/python-json-patch/actions
  • Coveralls: https://coveralls.io/github/stefankoegl/python-json-patch

String append extension

JsonPatchWithAppend is a drop-in replacement for JsonPatch with a non-RFC string append operation. Its from_diff() method sends only the new suffix when an object member's string grows. JsonPatch, make_patch() and apply_patch() retain their standard RFC 6902 behavior.

See the tutorial for examples. Both sender and receiver must support the extension.

Type hints

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

Running tests

pip install -r requirements.txt -r requirements-dev.txt
python tests.py

Running external tests

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

Running property-based tests

Property-based tests using Hypothesis are in property_tests.py.

pip install hypothesis
python property_tests.py

Set HYPOTHESIS_PROFILE=thorough to run many more examples.

About

Applying JSON Patches in Python

python-json-patch.readthedocs.org/

Topics

jsonjson-patchpythonpython-json

Resources

Readme
BSD-3-Clause license
Activity

Stars

500 stars

Watchers

6 watching

Forks

126 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.