MCPcopy Index your code
hub / github.com/python/cpython / raw_decode

Method raw_decode

Lib/json/decoder.py:364–377  ·  view source on GitHub ↗

Decode a JSON document from ``s`` (a ``str`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. This can be used to decode a JSON document from a string that may have extraneous data at t

(self, s, idx=0)

Source from the content-addressed store, hash-verified

362 return obj
363
364 def raw_decode(self, s, idx=0):
365 """Decode a JSON document from ``s`` (a ``str`` beginning with
366 a JSON document) and return a 2-tuple of the Python
367 representation and the index in ``s`` where the document ended.
368
369 This can be used to decode a JSON document from a string that may
370 have extraneous data at the end.
371
372 """
373 try:
374 obj, end = self.scan_once(s, idx)
375 except StopIteration as err:
376 raise JSONDecodeError("Expecting value", s, err.value) from None
377 return obj, end

Callers 1

decodeMethod · 0.95

Calls 1

JSONDecodeErrorClass · 0.85

Tested by

no test coverage detected