🔵 🔵 🔵


Primary

၊၊||၊|။

json.load() ⚬|Documentation|1st|20260208195155-00-⌔

json — JSON encoder and decoder — Python 3.14.3 documentation#json.load

json.load(fp, ﹡, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, ﹡﹡kw)

Deserialize fp to a Python object using the JSON-to-Python conversion table.

Parameters:
  • fp (file-like object) – A .read() -supporting text file or binary file containing the JSON document to be deserialized.
  • cls (a JSONDecoder subclass) – If set, a custom JSON decoder. Additional keyword arguments to load() will be passed to the constructor of cls. If None (the default), JSONDecoder is used.
  • object_hook (callable | None) – If set, a function that is called with the result of any JSON object literal decoded (a dict). The return value of this function will be used instead of the dict. This feature can be used to implement custom decoders, for example JSON-RPC class hinting. Default None.
  • object_pairs_hook (callable | None) – If set, a function that is called with the result of any JSON object literal decoded with an ordered list of pairs. The return value of this function will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also set, object_pairs_hook takes priority. Default None.
  • parse_float (callable | None) – If set, a function that is called with the string of every JSON float to be decoded. If None (the default), it is equivalent to float(num_str). This can be used to parse JSON floats into custom datatypes, for example decimal.Decimal.
  • parse_int (callable | None) – If set, a function that is called with the string of every JSON int to be decoded. If None (the default), it is equivalent to int(num_str). This can be used to parse JSON integers into custom datatypes, for example float.
  • parse_constant (callable | None) – If set, a function that is called with one of the following strings: '-Infinity', 'Infinity', or 'NaN'. This can be used to raise an exception if invalid JSON numbers are encountered. Default None.
Raises:
  • JSONDecodeError – When the data being deserialized is not a valid JSON document.
  • UnicodeDecodeError – When the data being deserialized does not contain UTF-8, UTF-16 or UTF-32 encoded data.

Changed in version 3.1:

  • Added the optional object_pairs_hook parameter.
  • parse_constant doesn’t get called on ‘null’, ‘true’, ‘false’ anymore.

Changed in version 3.6:

  • All optional parameters are now keyword-only.
  • fp can now be a binary file. The input encoding should be UTF-8, UTF-16 or UTF-32.

Changed in version 3.11: The default parse_int of int() now limits the maximum length of the integer string via the interpreter’s integer string conversion length limitation to help avoid denial of service attacks.

Printed 2026-06-28.

(echo:: @ )

Link to original

Secondary

• • •