Skip to main content

JSON Patch for modern PATCH APIs.

Project description

JsonPatchX

Tests Codecov OpenSSF Scorecard Contributor Covenant PyPI Version Python Versions License

JSON Patch for modern PATCH APIs. Tested against the RFC 6902 Compliance Test Suite.

Built on Pydantic models, with typed JSON Pointer / JSONPath targeting, custom patch operations, and first-class support for FastAPI PATCH routes and OpenAPI generation.

Table of Contents

Install

pip install jsonpatchx

For FastAPI integrations:

pip install jsonpatchx[fastapi]

Links

Examples

1. Standard RFC 6902

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)

2. The FastAPI Contract

from fastapi import FastAPI
from pydantic import BaseModel, EmailStr
from jsonpatchx import JsonPatchFor

class User(BaseModel):
    id: int
    email: EmailStr
    active: bool

app = FastAPI()

@app.patch("/users/{user_id}", response_model=User)
def patch_user(user_id: int, patch: JsonPatchFor[User]) -> User:
    user = load_user(user_id)
    updated = patch.apply(user)
    save_user(user_id, updated)
    return updated

Note: For custom operations, JSONPath targeting, route-level controls, and more, see the User Guide.

Contributing

See CONTRIBUTING.md for local setup, checks, docs preview, and pull request expectations.

Use Discussions for project-specific design conversation, issues for concrete bugs or proposed work, and the broader json-patch2 forum for standards discussion.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Angela Liss - chamsester@gmail.com

Project Link: https://github.com/angela-tarantula/jsonpatchx

Acknowledgements

Thanks to these foundational projects:

And to these excellent alternatives:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonpatchx-0.1.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonpatchx-0.1.0-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file jsonpatchx-0.1.0.tar.gz.

File metadata

  • Download URL: jsonpatchx-0.1.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jsonpatchx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 234d3b725d2751a81ef51930b0e8c336fa2c5491be7a843b1a85b08c824f1ade
MD5 e504b809d3ee49fa957319a55a98af11
BLAKE2b-256 cecc61d30b11cf2690aeea783b460587d9952a04187679cae5b913b01751e92a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonpatchx-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on angela-tarantula/jsonpatchx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jsonpatchx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jsonpatchx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jsonpatchx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bce314a19515090dc464ce11fa59e66905c2eda9b51bfbf0897ccbae68c8034
MD5 9d2f52e33b109f0c04f701bb63eb4573
BLAKE2b-256 f34a9963ceeb4f114a9f87e318226c0b44e0f9b394e983f809bb27a86cdd4562

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonpatchx-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on angela-tarantula/jsonpatchx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page