summaryrefslogtreecommitdiff
path: root/jsonpointer.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonpointer.py')
-rw-r--r--jsonpointer.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/jsonpointer.py b/jsonpointer.py
index 06b9869..58cbdbb 100644
--- a/jsonpointer.py
+++ b/jsonpointer.py
@@ -40,8 +40,14 @@ __website__ = 'https://github.com/stefankoegl/python-json-pointer'
__license__ = 'Modified BSD License'
-import urllib
-from itertools import tee, izip
+try:
+ from urllib import unquote
+ from itertools import izip
+except ImportError: # Python 3
+ from urllib.parse import unquote
+ izip = zip
+
+from itertools import tee
class JsonPointerException(Exception):
@@ -121,7 +127,7 @@ class JsonPointer(object):
if parts.pop(0) != '':
raise JsonPointerException('location must starts with /')
- parts = map(urllib.unquote, parts)
+ parts = map(unquote, parts)
parts = [part.replace('~1', '/') for part in parts]
parts = [part.replace('~0', '~') for part in parts]
self.parts = parts