💾 Archived View for tris.fyi › pydoc › json.decoder captured on 2023-01-29 at 04:14:39. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
Implementation of JSONDecoder
Subclass of ValueError with the following additional properties: msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed lineno: The line corresponding to pos colno: The column corresponding to pos
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
Simple JSON <https://json.org> decoder Performs the following translations in decoding by default: +---------------+-------------------+ | JSON | Python | +===============+===================+ | object | dict | +---------------+-------------------+ | array | list | +---------------+-------------------+ | string | str | +---------------+-------------------+ | number (int) | int | +---------------+-------------------+ | number (real) | float | +---------------+-------------------+ | true | True | +---------------+-------------------+ | false | False | +---------------+-------------------+ | null | None | +---------------+-------------------+ It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their corresponding ``float`` values, which is outside the JSON spec.
decode(self, s, _w=<built-in method match of re.Pattern object at 0x7f75e2e72a80>) Return the Python representation of ``s`` (a ``str`` instance containing a JSON document).
raw_decode(self, s, idx=0) 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 the end.
JSONArray(s_and_end, scan_once, _w=<built-in method match of re.Pattern object at 0x7f75e2e72a80>, _ws=' \t\n\r')
JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook, memo=None, _w=<built-in method match of re.Pattern object at 0x7f75e2e72a80>, _ws=' \t\n\r')
scanstring(...) scanstring(string, end, strict=True) -> (string, end) Scan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. Unescapes all valid JSON string escape sequences and raises ValueError on attempt to decode an invalid string. If strict is False then literal control characters are allowed in the string. Returns a tuple of the decoded string and the index of the character in s after the end quote.
py_scanstring(s, end, strict=True, _b={'"': '"', '\\': '\\', '/': '/', 'b': '\x08', 'f': '\x0c', 'n': '\n', 'r': '\r', 't': '\t'}, _m=<built-in method match of re.Pattern object at 0x7f75e2dab790>) Scan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. Unescapes all valid JSON string escape sequences and raises ValueError on attempt to decode an invalid string. If strict is False then literal control characters are allowed in the string. Returns a tuple of the decoded string and the index of the character in s after the end quote.
scanstring(...) scanstring(string, end, strict=True) -> (string, end) Scan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. Unescapes all valid JSON string escape sequences and raises ValueError on attempt to decode an invalid string. If strict is False then literal control characters are allowed in the string. Returns a tuple of the decoded string and the index of the character in s after the end quote.
BACKSLASH = {'"': '"', '\\': '\\', '/': '/', 'b': '\x08', 'f': '\x0c', 'n': '\n', 'r': '\r', 't': '\t'}
FLAGS = re.MULTILINE|re.DOTALL|re.VERBOSE
NaN = nan
NegInf = -inf
PosInf = inf
STRINGCHUNK = re.compile('(.*?)(["\\\\\\x00-\\x1f])', re.MULTILINE|re.DOTALL|re.VERBOSE)
WHITESPACE = re.compile('[ \\t\\n\\r]*', re.MULTILINE|re.DOTALL|re.VERBOSE)
WHITESPACE_STR = ' \t\n\r'