Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a JSON document as `str` or `bytes`) to a Python object. *encoding* determines the encoding used to interpret any `bytes` objects decoded by this instance (``'utf-8'`` by default). It has no effect when decodin
(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None,
use_decimal=False, allow_nan=False, array_hook=None, **kw)
| 400 | |
| 401 | |
| 402 | def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None, |
| 403 | parse_int=None, parse_constant=None, object_pairs_hook=None, |
| 404 | use_decimal=False, allow_nan=False, array_hook=None, **kw): |
| 405 | """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing |
| 406 | a JSON document as `str` or `bytes`) to a Python object. |
| 407 | |
| 408 | *encoding* determines the encoding used to interpret any |
| 409 | `bytes` objects decoded by this instance (``'utf-8'`` by |
| 410 | default). It has no effect when decoding `str` objects. |
| 411 | |
| 412 | *object_hook*, if specified, will be called with the result of every |
| 413 | JSON object decoded and its return value will be used in place of the |
| 414 | given :class:`dict`. This can be used to provide custom |
| 415 | deserializations (e.g. to support JSON-RPC class hinting). |
| 416 | |
| 417 | *object_pairs_hook* is an optional function that will be called with |
| 418 | the result of any object literal decode with an ordered list of pairs. |
| 419 | The return value of *object_pairs_hook* will be used instead of the |
| 420 | :class:`dict`. This feature can be used to implement custom decoders |
| 421 | that rely on the order that the key and value pairs are decoded (for |
| 422 | example, :func:`collections.OrderedDict` will remember the order of |
| 423 | insertion). If *object_hook* is also defined, the *object_pairs_hook* |
| 424 | takes priority. |
| 425 | |
| 426 | *parse_float*, if specified, will be called with the string of every |
| 427 | JSON float to be decoded. By default, this is equivalent to |
| 428 | ``float(num_str)``. This can be used to use another datatype or parser |
| 429 | for JSON floats (e.g. :class:`decimal.Decimal`). |
| 430 | |
| 431 | *parse_int*, if specified, will be called with the string of every |
| 432 | JSON int to be decoded. By default, this is equivalent to |
| 433 | ``int(num_str)``. This can be used to use another datatype or parser |
| 434 | for JSON integers (e.g. :class:`float`). |
| 435 | |
| 436 | *allow_nan*, if True (default false), will allow the parser to |
| 437 | accept the non-standard floats ``NaN``, ``Infinity``, and ``-Infinity`` |
| 438 | and enable the use of the deprecated *parse_constant*. |
| 439 | |
| 440 | If *use_decimal* is true (default: ``False``) then it implies |
| 441 | parse_float=decimal.Decimal for parity with ``dump``. |
| 442 | |
| 443 | *parse_constant*, if specified, will be |
| 444 | called with one of the following strings: ``'-Infinity'``, |
| 445 | ``'Infinity'``, ``'NaN'``. It is not recommended to use this feature, |
| 446 | as it is rare to parse non-compliant JSON containing these values. |
| 447 | |
| 448 | To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` |
| 449 | kwarg. NOTE: You should use *object_hook* or *object_pairs_hook* instead |
| 450 | of subclassing whenever possible. |
| 451 | |
| 452 | """ |
| 453 | return loads(fp.read(), |
| 454 | encoding=encoding, cls=cls, object_hook=object_hook, |
| 455 | parse_float=parse_float, parse_int=parse_int, |
| 456 | parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, |
| 457 | use_decimal=use_decimal, allow_nan=allow_nan, |
| 458 | array_hook=array_hook, **kw) |
| 459 |
nothing calls this directly
no test coverage detected
searching dependent graphs…