diff options
author | Stefan Kögl <stefan@skoegl.net> | 2011-06-20 16:04:04 +0200 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2011-06-20 16:04:04 +0200 |
commit | bc94e060692df03585d853750ae01f2314f64101 (patch) | |
tree | 28b7a879a2ebcd4ab2fc55bcbf249e7e0bb529c9 /jsonpatch.py | |
parent | df999c9b43b931bc4d83b816754d63a34b7c4c70 (diff) | |
download | python-json-patch-bc94e060692df03585d853750ae01f2314f64101.tar.gz |
add shortcut jsonpatch.apply_patch(doc, patch)
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 """ |