diff options
Diffstat (limited to 'jsonpatch.py')
-rw-r--r-- | jsonpatch.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/jsonpatch.py b/jsonpatch.py index 3136567..d75e27c 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -47,6 +47,18 @@ class JsonPatchException(Exception): pass +def apply_patch(doc, patch): + """ + >>> obj = { 'baz': 'qux', 'foo': 'bar' } + >>> patch = [ { 'remove': '/baz' } ] + >>> apply_patch(obj, patch) + {'foo': 'bar'} + """ + + p = JsonPatch(patch) + return p.apply(doc) + + class JsonPatch(object): """ A JSON Patch is a list of Patch Operations """ |