From 0fb0aeabc0af49bb127deb11ecddf66fa7a3d58c Mon Sep 17 00:00:00 2001 From: Janne Kulmala Date: Thu, 19 Jul 2012 13:04:19 +0300 Subject: raw_decode(): Skip whitespace before the object --- simplejson/decoder.py | 6 +++--- 1 file 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 -- cgit v1.2.1