Add a function for performing a JSON Patch.

Review Request #9264 - Created Oct. 12, 2017 and updated

Christian Hammond
Djblets
release-0.10.x
2df79c3...
djblets

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 to null, 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, and test. 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.

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Christian Hammond
Review request changed

Change Summary:

  • Improved documentation.
  • Fixed alignment issues.

Commit:

-7282b972265569f604147a7e594c18afd530ef27
+2df79c3eaf5620121f813340fbc19d1fb24e9250

Diff:

Revision 2 (+2690 -2)

Show changes

Checks run (2 succeeded)

JSHint passed.
flake8 passed.
Loading...