2021-01-24 22:49:28 -05:00
|
|
|
:mod:`json` -- JSON encoding and decoding
|
2014-10-31 22:21:37 +00:00
|
|
|
==========================================
|
2014-10-31 01:37:19 +00:00
|
|
|
|
2021-01-24 22:49:28 -05:00
|
|
|
.. module:: json
|
2014-10-31 01:37:19 +00:00
|
|
|
:synopsis: JSON encoding and decoding
|
|
|
|
|
2018-02-20 17:34:59 -08:00
|
|
|
|see_cpython_module| :mod:`cpython:json`.
|
2017-07-02 15:37:31 +03:00
|
|
|
|
2014-10-31 01:37:19 +00:00
|
|
|
This modules allows to convert between Python objects and the JSON
|
|
|
|
data format.
|
|
|
|
|
|
|
|
Functions
|
|
|
|
---------
|
|
|
|
|
2018-02-06 15:48:24 +11:00
|
|
|
.. function:: dump(obj, stream)
|
|
|
|
|
2018-07-23 21:34:25 -04:00
|
|
|
Serialise ``obj`` to a JSON string, writing it to the given *stream*.
|
2018-02-06 15:48:24 +11:00
|
|
|
|
2014-10-31 01:37:19 +00:00
|
|
|
.. function:: dumps(obj)
|
|
|
|
|
2018-07-23 21:34:25 -04:00
|
|
|
Return ``obj`` represented as a JSON string.
|
2014-10-31 01:37:19 +00:00
|
|
|
|
2018-02-06 15:48:24 +11:00
|
|
|
.. function:: load(stream)
|
|
|
|
|
2018-07-23 21:34:25 -04:00
|
|
|
Parse the given ``stream``, interpreting it as a JSON string and
|
2018-02-06 15:48:24 +11:00
|
|
|
deserialising the data to a Python object. The resulting object is
|
|
|
|
returned.
|
|
|
|
|
|
|
|
Parsing continues until end-of-file is encountered.
|
2018-07-23 21:34:25 -04:00
|
|
|
A :exc:`ValueError` is raised if the data in ``stream`` is not correctly formed.
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
.. function:: loads(str)
|
|
|
|
|
2018-02-15 11:31:34 +11:00
|
|
|
Parse the JSON *str* and return an object. Raises :exc:`ValueError` if the
|
2014-10-31 01:37:19 +00:00
|
|
|
string is not correctly formed.
|