add shortcut jsonpatch.apply_patch(doc, patch)
This commit is contained in:
12
jsonpatch.py
12
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 """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user