MCPcopy Index your code
hub / github.com/clips/pattern / raw_decode

Method raw_decode

pattern/web/json/decoder.py:412–427  ·  view source on GitHub ↗

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. Optionally, ``idx`` can be used to specify an offset in ``s`` where the JSON

(self, s, idx=0, _w=WHITESPACE.match)

Source from the content-addressed store, hash-verified

410 return obj
411
412 def raw_decode(self, s, idx=0, _w=WHITESPACE.match):
413 """Decode a JSON document from ``s`` (a ``str`` or ``unicode``
414 beginning with a JSON document) and return a 2-tuple of the Python
415 representation and the index in ``s`` where the document ended.
416 Optionally, ``idx`` can be used to specify an offset in ``s`` where
417 the JSON document begins.
418
419 This can be used to decode a JSON document from a string that may
420 have extraneous data at the end.
421
422 """
423 try:
424 obj, end = self.scan_once(s, idx=_w(s, idx).end())
425 except StopIteration:
426 raise JSONDecodeError("No JSON object could be decoded", s, idx)
427 return obj, end

Callers 1

decodeMethod · 0.95

Calls 1

JSONDecodeErrorClass · 0.85

Tested by

no test coverage detected