summaryrefslogtreecommitdiff
path: root/jsonpointer.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonpointer.py')
-rw-r--r--jsonpointer.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/jsonpointer.py b/jsonpointer.py
index d353632..3eaea19 100644
--- a/jsonpointer.py
+++ b/jsonpointer.py
@@ -44,8 +44,10 @@ __license__ = 'Modified BSD License'
try:
from itertools import izip
str = unicode
+ encode_str = lambda u: u.encode("raw_unicode_escape")
except ImportError: # Python 3
izip = zip
+ encode_str = lambda u: u
try:
from collections.abc import Mapping, Sequence
@@ -322,6 +324,12 @@ class JsonPointer(object):
def __hash__(self):
return hash(tuple(self.parts))
+ def __str__(self):
+ return encode_str(self.path)
+
+ def __repr__(self):
+ return "JsonPointer(" + repr(self.path) + ")"
+
@classmethod
def from_parts(cls, parts):
"""Constructs a JsonPointer from a list of (unescaped) paths