summaryrefslogtreecommitdiff
path: root/jsonpatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonpatch.py')
-rw-r--r--jsonpatch.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index a28af75..5e538dd 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -146,12 +146,20 @@ class JsonPatch(object):
'test': TestOperation
}
+ def __str__(self):
+ """str(self) -> self.to_string()"""
+ return self.to_string()
+
@classmethod
def from_string(cls, patch_str):
"""Creates JsonPatch instance from string source."""
patch = json.loads(patch_str)
return cls(patch)
+ def to_string(self):
+ """Returns patch set as JSON string."""
+ return json.dumps(self.patch)
+
def apply(self, obj):
"""Applies the patch to given object."""