Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Scrub invalid json before passing it to the parser.

  • Loading branch information...
commit 7c38c94827d67097a7a0e4fcdb89d22902286017 1 parent 66c4923
@robottwo authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 itunes/__init__.py
View
7 itunes/__init__.py
@@ -29,6 +29,12 @@
__cache_enabled = False # Enable cache? if set to True, make sure that __cache_dir exists! (e.g. $ mkdir ./cache)
__cache_dir = './cache' # Set cache directory
+
+
+def clean_json(data):
+ return data.replace('\\\\', r'//').replace(r"\'", '\"').replace(r'\"', '').replace(r'\u','')
+
+
class ServiceException(Exception):
"""Exception related to the web service."""
@@ -83,6 +89,7 @@ def execute(self, cacheable=False):
response = self._get_cached_response()
else:
response = self._download_response()
+ response = clean_json(response)
return json.loads(response)
except urllib2.HTTPError, e:
raise self._get_error(e.fp.read())
Please sign in to comment.
Something went wrong with that request. Please try again.