Markdown Format | JSON API | MCP Server Tool
Help on module jsonpatch: NAME jsonpatch - Apply JSON-Patches (RFC 6902) CLASSES builtins.Exception(builtins.BaseException) JsonPatchException InvalidJsonPatch JsonPatchConflict JsonPatchTestFailed(JsonPatchException, builtins.AssertionError) builtins.object DiffBuilder JsonPatch PatchOperation AddOperation CopyOperation MoveOperation RemoveOperation ReplaceOperation TestOperation class AddOperation(PatchOperation) | AddOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Adds an object property or an array element. | | Method resolution order: | AddOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class CopyOperation(PatchOperation) | CopyOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Copies an object property or an array element to a new location | | Method resolution order: | CopyOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class DiffBuilder(builtins.object) | DiffBuilder(src_doc, dst_doc, dumps=<function dumps at 0x7fc78c739bd0>, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Methods defined here: | | __init__(self, src_doc, dst_doc, dumps=<function dumps at 0x7fc78c739bd0>, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) | | execute(self) | | insert(self, op) | | iter_from(self, start) | | remove(self, index) | | store_index(self, value, index, st) | | take_index(self, value, st) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class InvalidJsonPatch(JsonPatchException) | Raised if an invalid JSON Patch is created | | Method resolution order: | InvalidJsonPatch | JsonPatchException | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from JsonPatchException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class JsonPatch(builtins.object) | JsonPatch(patch, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Methods defined here: | | __bool__(self) | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, patch, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) | | __ne__(self, other) | Return self!=value. | | __nonzero__ = __bool__(self) | | __str__(self) | str(self) -> self.to_string() | | apply(self, obj, in_place=False) | Applies the patch to a given object. | | :param obj: Document object. | :type obj: dict | | :param in_place: Tweaks the way how patch would be applied - directly to | specified `obj` or to its copy. | :type in_place: bool | | :return: Modified `obj`. | | to_string(self, dumps=None) | Returns patch set as JSON string. | | ---------------------------------------------------------------------- | Class methods defined here: | | from_diff(src, dst, optimization=True, dumps=None, pointer_cls=<class 'jsonpointer.JsonPointer'>) from builtins.type | Creates JsonPatch instance based on comparison of two document | objects. Json patch would be created for `src` argument against `dst` | one. | | :param src: Data source document object. | :type src: dict | | :param dst: Data source document object. | :type dst: dict | | :param dumps: A function of one argument that produces a serialized | JSON string. | :type dumps: function | | :param pointer_cls: JSON pointer class to use. | :type pointer_cls: Type[JsonPointer] | | :return: :class:`JsonPatch` instance. | | >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]} | >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]} | >>> patch = JsonPatch.from_diff(src, dst) | >>> new = patch.apply(src) | >>> new == dst | True | | from_string(patch_str, loads=None, pointer_cls=<class 'jsonpointer.JsonPointer'>) from builtins.type | Creates JsonPatch instance from string source. | | :param patch_str: JSON patch as raw string. | :type patch_str: str | | :param loads: A function of one argument that loads a serialized | JSON string. | :type loads: function | | :param pointer_cls: JSON pointer class to use. | :type pointer_cls: Type[JsonPointer] | | :return: :class:`JsonPatch` instance. | | ---------------------------------------------------------------------- | Static methods defined here: | | json_dumper = dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw) | Serialize ``obj`` to a JSON formatted ``str``. | | If ``skipkeys`` is true then ``dict`` keys that are not basic types | (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped | instead of raising a ``TypeError``. | | If ``ensure_ascii`` is false, then the return value can contain non-ASCII | characters if they appear in strings contained in ``obj``. Otherwise, all | such characters are escaped in JSON strings. | | If ``check_circular`` is false, then the circular reference check | for container types will be skipped and a circular reference will | result in an ``RecursionError`` (or worse). | | If ``allow_nan`` is false, then it will be a ``ValueError`` to | serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in | strict compliance of the JSON specification, instead of using the | JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). | | If ``indent`` is a non-negative integer, then JSON array elements and | object members will be pretty-printed with that indent level. An indent | level of 0 will only insert newlines. ``None`` is the most compact | representation. | | If specified, ``separators`` should be an ``(item_separator, key_separator)`` | tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and | ``(',', ': ')`` otherwise. To get the most compact JSON representation, | you should specify ``(',', ':')`` to eliminate whitespace. | | ``default(obj)`` is a function that should return a serializable version | of obj or raise TypeError. The default simply raises TypeError. | | If *sort_keys* is true (default: ``False``), then the output of | dictionaries will be sorted by key. | | To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the | ``.default()`` method to serialize additional types), specify it with | the ``cls`` kwarg; otherwise ``JSONEncoder`` is used. | | json_loader = functools.partial(<function loads at 0x7fc78c73a...airs_hook=<function multidict at 0x7fc78c738790>) | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | operations = mappingproxy({'remove': <class 'jsonpatch.Remove...on'>, ... class JsonPatchConflict(JsonPatchException) | Raised if patch could not be applied due to conflict situation such as: | - attempt to add object key when it already exists; | - attempt to operate with nonexistence object key; | - attempt to insert value to array at position beyond its size; | - etc. | | Method resolution order: | JsonPatchConflict | JsonPatchException | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from JsonPatchException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class JsonPatchException(builtins.Exception) | Base Json Patch exception | | Method resolution order: | JsonPatchException | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class JsonPatchTestFailed(JsonPatchException, builtins.AssertionError) | A Test operation failed | | Method resolution order: | JsonPatchTestFailed | JsonPatchException | builtins.AssertionError | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from JsonPatchException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.AssertionError: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.AssertionError: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class MoveOperation(PatchOperation) | MoveOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Moves an object property or an array element to a new location. | | Method resolution order: | MoveOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | from_path | | ---------------------------------------------------------------------- | Data descriptors defined here: | | from_key | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class PatchOperation(builtins.object) | PatchOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | A single operation inside a JSON Patch. | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | path | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class RemoveOperation(PatchOperation) | RemoveOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Removes an object property or an array element. | | Method resolution order: | RemoveOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class ReplaceOperation(PatchOperation) | ReplaceOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Replaces an object property or an array element by a new value. | | Method resolution order: | ReplaceOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key class TestOperation(PatchOperation) | TestOperation(operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | | Test value by specified location. | | Method resolution order: | TestOperation | PatchOperation | builtins.object | | Methods defined here: | | apply(self, obj) | Abstract method that applies a patch operation to the specified object. | | ---------------------------------------------------------------------- | Methods inherited from PatchOperation: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, operation, pointer_cls=<class 'jsonpointer.JsonPointer'>) | Initialize self. See help(type(self)) for accurate signature. | | __ne__(self, other) | Return self!=value. | | ---------------------------------------------------------------------- | Readonly properties inherited from PatchOperation: | | path | | ---------------------------------------------------------------------- | Data descriptors inherited from PatchOperation: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | key FUNCTIONS apply_patch(doc, patch, in_place=False, pointer_cls=<class 'jsonpointer.JsonPointer'>) Apply list of patches to specified json document. :param doc: Document object. :type doc: dict :param patch: JSON patch as list of dicts or raw JSON-encoded string. :type patch: list or str :param in_place: While :const:`True` patch will modify target document. By default patch will be applied to document copy. :type in_place: bool :param pointer_cls: JSON pointer class to use. :type pointer_cls: Type[JsonPointer] :return: Patched document object. :rtype: dict >>> doc = {'foo': 'bar'} >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}] >>> other = apply_patch(doc, patch) >>> doc is not other True >>> other == {'foo': 'bar', 'baz': 'qux'} True >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}] >>> apply_patch(doc, patch, in_place=True) == {'foo': 'bar', 'baz': 'qux'} True >>> doc == other True make_patch(src, dst, pointer_cls=<class 'jsonpointer.JsonPointer'>) Generates patch by comparing two document objects. Actually is a proxy to :meth:`JsonPatch.from_diff` method. :param src: Data source document object. :type src: dict :param dst: Data source document object. :type dst: dict :param pointer_cls: JSON pointer class to use. :type pointer_cls: Type[JsonPointer] >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]} >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]} >>> patch = make_patch(src, dst) >>> new = patch.apply(src) >>> new == dst True multidict(ordered_pairs) Convert duplicate keys values to lists. DATA __license__ = 'Modified BSD License' __website__ = 'https://github.com/stefankoegl/python-json-patch' basestring = (<class 'bytes'>, <class 'str'>) unicode_literals = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', ... VERSION 1.32 AUTHOR Stefan Kögl <stefan AT skoegl.net> FILE /usr/lib/python3/dist-packages/jsonpatch.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:13 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)