MCPcopy Create free account
hub / github.com/simplejson/simplejson / decode

Method decode

simplejson/decoder.py:389–400  ·  view source on GitHub ↗

Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document)

(self, s, _w=WHITESPACE.match, _PY3=PY3)

Source from the content-addressed store, hash-verified

387 self.scan_once = make_scanner(self)
388
389 def decode(self, s, _w=WHITESPACE.match, _PY3=PY3):
390 """Return the Python representation of ``s`` (a ``str`` or ``unicode``
391 instance containing a JSON document)
392
393 """
394 if _PY3 and isinstance(s, bytes):
395 s = str(s, self.encoding)
396 obj, end = self.raw_decode(s)
397 end = _w(s, end).end()
398 if end != len(s):
399 raise JSONDecodeError("Extra data", s, end, len(s))
400 return obj
401
402 def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):
403 """Decode a JSON document from ``s`` (a ``str`` or ``unicode``

Callers 2

loadsFunction · 0.45

Calls 2

raw_decodeMethod · 0.95
JSONDecodeErrorClass · 0.85

Tested by

no test coverage detected