Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a JSON document) to a Python object. ``object_hook`` is an optional function that will be called with the result of any object literal decode (a ``dict``). The return value of ``object_hook`` will be used inste
(fp, *, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None,
array_hook=None, **kw)
| 275 | |
| 276 | |
| 277 | def load(fp, *, cls=None, object_hook=None, parse_float=None, |
| 278 | parse_int=None, parse_constant=None, object_pairs_hook=None, |
| 279 | array_hook=None, **kw): |
| 280 | """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing |
| 281 | a JSON document) to a Python object. |
| 282 | |
| 283 | ``object_hook`` is an optional function that will be called with the |
| 284 | result of any object literal decode (a ``dict``). The return value of |
| 285 | ``object_hook`` will be used instead of the ``dict``. This feature |
| 286 | can be used to implement custom decoders (e.g. JSON-RPC class hinting). |
| 287 | |
| 288 | ``object_pairs_hook`` is an optional function that will be called with |
| 289 | the result of any object literal decoded with an ordered list of pairs. |
| 290 | The return value of ``object_pairs_hook`` will be used instead of the |
| 291 | ``dict``. This feature can be used to implement custom decoders. If |
| 292 | ``object_hook`` is also defined, the ``object_pairs_hook`` takes |
| 293 | priority. |
| 294 | |
| 295 | ``array_hook`` is an optional function that will be called with the result |
| 296 | of any literal array decode (a ``list``). The return value of this function will |
| 297 | be used instead of the ``list``. This feature can be used along |
| 298 | ``object_pairs_hook`` to customize the resulting data structure - for example, |
| 299 | by setting that to ``frozendict`` and ``array_hook`` to ``tuple``, one can get |
| 300 | a deep immutable data structute from any JSON data. |
| 301 | |
| 302 | To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` |
| 303 | kwarg; otherwise ``JSONDecoder`` is used. |
| 304 | """ |
| 305 | return loads(fp.read(), |
| 306 | cls=cls, object_hook=object_hook, |
| 307 | parse_float=parse_float, parse_int=parse_int, |
| 308 | parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, |
| 309 | array_hook=None, **kw) |
| 310 | |
| 311 | |
| 312 | def loads(s, *, cls=None, object_hook=None, parse_float=None, |