c737cde947
Anywhere a module is mentioned, use its "non-u" name for consistency. The "import module" vs "import umodule" is something of a FAQ, and this commit intends to help clear that up. As a first approximation MicroPython is Python, and so imports should work the same as Python and use the same name, to a first approximation. The u-version of a module is a detail that can be learned later on, when the user wants to understand more and have finer control over importing. Existing Python code should just work, as much as it is possible to do that within the constraints of embedded systems, and the MicroPython documentation should match the idiomatic way to write Python code. With universal weak links for modules (via MICROPY_MODULE_WEAK_LINKS) users can consistently use "import foo" across all ports (with the exception of the minimal ports). And the ability to override/extend via "foo.py" continues to work well. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
42 lines
1.2 KiB
ReStructuredText
42 lines
1.2 KiB
ReStructuredText
:mod:`json` -- JSON encoding and decoding
|
|
=========================================
|
|
|
|
.. module:: json
|
|
:synopsis: JSON encoding and decoding
|
|
|
|
|see_cpython_module| :mod:`python:json`.
|
|
|
|
This modules allows to convert between Python objects and the JSON
|
|
data format.
|
|
|
|
Functions
|
|
---------
|
|
|
|
.. function:: dump(obj, stream, separators=None)
|
|
|
|
Serialise *obj* to a JSON string, writing it to the given *stream*.
|
|
|
|
If specified, separators should be an ``(item_separator, key_separator)``
|
|
tuple. The default is ``(', ', ': ')``. To get the most compact JSON
|
|
representation, you should specify ``(',', ':')`` to eliminate whitespace.
|
|
|
|
.. function:: dumps(obj, separators=None)
|
|
|
|
Return *obj* represented as a JSON string.
|
|
|
|
The arguments have the same meaning as in `dump`.
|
|
|
|
.. function:: load(stream)
|
|
|
|
Parse the given *stream*, interpreting it as a JSON string and
|
|
deserialising the data to a Python object. The resulting object is
|
|
returned.
|
|
|
|
Parsing continues until end-of-file is encountered.
|
|
A :exc:`ValueError` is raised if the data in *stream* is not correctly formed.
|
|
|
|
.. function:: loads(str)
|
|
|
|
Parse the JSON *str* and return an object. Raises :exc:`ValueError` if the
|
|
string is not correctly formed.
|