diff options
author | Janne Kulmala <janne.t.kulmala@tut.fi> | 2012-07-19 13:04:19 +0300 |
---|---|---|
committer | Janne Kulmala <janne.t.kulmala@tut.fi> | 2012-07-19 13:04:19 +0300 |
commit | 0fb0aeabc0af49bb127deb11ecddf66fa7a3d58c (patch) | |
tree | c5ec429f622256ecd5b3df2860e2e9c9efa9b516 | |
parent | f55e882aafa73732d63129cf1280c093acc916db (diff) | |
download | simplejson-0fb0aeabc0af49bb127deb11ecddf66fa7a3d58c.tar.gz |
raw_decode(): Skip whitespace before the object
-rw-r--r-- | simplejson/decoder.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/simplejson/decoder.py b/simplejson/decoder.py index 20e04b8..1c1526c 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -403,13 +403,13 @@ class JSONDecoder(object): instance containing a JSON document) """ - obj, end = self.raw_decode(s, idx=_w(s, 0).end()) + obj, end = self.raw_decode(s) end = _w(s, end).end() if end != len(s): raise JSONDecodeError("Extra data", s, end, len(s)) return obj - def raw_decode(self, s, idx=0): + def raw_decode(self, s, idx=0, _w=WHITESPACE.match): """Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. @@ -421,7 +421,7 @@ class JSONDecoder(object): """ try: - obj, end = self.scan_once(s, idx) + obj, end = self.scan_once(s, idx=_w(s, idx).end()) except StopIteration: raise JSONDecodeError("No JSON object could be decoded", s, idx) return obj, end |