Add a function for performing a JSON Patch.
Review Request #9264 — Created Oct. 12, 2017 and submitted
This introduces
djblets.util.json_utils.json_patch
, an implementation
of JSON Patch (RFC 6902). This is another, more advanced method of
patching JSON-serializable data, sort of like with JSON Merge Patch but
with the ability to order operations, copy or move data, sanity-check
values before applying a patch, set values tonull
, and manipulate
specific indices of arrays. It's a good substitute for JSON Merge
Patches when more specific modifications and sanity-checking is needed.JSON Patches consist of a list of operations to perform. These are
add
,remove
,replace
,copy
,move
, andtest
. All operations
must pass in order for a patch to apply.This implementation goes beyond most implementations by providing read
and write access control for keys. This allows callers to prevent
reading certain keys or writing to others, limiting the damage that, for
instance, an API call can do.More information on JSON Patch can be found at http://jsonpatch.com/ or
https://tools.ietf.org/html/rfc6902.
Unit tests pass.
Description | From | Last Updated |
---|---|---|
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
Docstring? |
david | |
Typo: THe |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
JSON Pointer doesn't necessarily know about the operation, right? So it's possible that we might have '-' here, which JSON … |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david | |
Should this really be localized? |
david |
- Change Summary:
-
- Improved documentation.
- Fixed alignment issues.
- Commit:
-
7282b972265569f604147a7e594c18afd530ef272df79c3eaf5620121f813340fbc19d1fb24e9250
Checks run (2 succeeded)
- Change Summary:
-
- Added a missing docstring.
- Fixed typos in docstrings.
JSONPointerEndOfList
equality checks now returnFalse
if comparing against a non-JSONPointerEndOfList
.- Added checks (and unit tests) to make sure paths with
-
aren't being used for operations that don't support them.
- Commit:
-
2df79c3eaf5620121f813340fbc19d1fb24e9250899e5683fd6dc1feb7e13574f84d76f3db3a9f13
Checks run (2 succeeded)
- Change Summary:
-
- Renamed "target" to "doc" and fleshed out documentation to indicate that the original JSON document being patched is not actually modified itself.
- Fixed a small handful of doc errors and typos.
- Commit:
-
899e5683fd6dc1feb7e13574f84d76f3db3a9f136ffb09c74d36782f2c4be5bc24358d1ef0b8c550