summaryrefslogtreecommitdiff
path: root/Doc/library/json.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/json.rst')
-rw-r--r--Doc/library/json.rst34
1 files changed, 26 insertions, 8 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 517f9cecfd..8103c614aa 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -126,7 +126,7 @@ See :ref:`json-commandline` for detailed documentation.
Basic Usage
-----------
-.. function:: dump(obj, fp, skipkeys=False, ensure_ascii=True, \
+.. function:: dump(obj, fp, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -187,8 +187,11 @@ Basic Usage
:meth:`default` method to serialize additional types), specify it with the
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
-.. function:: dumps(obj, skipkeys=False, ensure_ascii=True, \
+
+.. function:: dumps(obj, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -212,7 +215,7 @@ Basic Usage
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
keys.
-.. function:: load(fp, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+.. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *fp* (a ``.read()``-supporting :term:`file-like object`
containing a JSON document) to a Python object using this :ref:`conversion
@@ -260,10 +263,14 @@ Basic Usage
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
-.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
+.. function:: loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
- Deserialize *s* (a :class:`str` instance containing a JSON document) to a
- Python object using this :ref:`conversion table <json-to-py-table>`.
+ Deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray`
+ instance containing a JSON document) to a Python object using this
+ :ref:`conversion table <json-to-py-table>`.
The other arguments have the same meaning as in :func:`load`, except
*encoding* which is ignored and deprecated.
@@ -271,10 +278,15 @@ Basic Usage
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
+ .. versionchanged:: 3.6
+ *s* can now be of type :class:`bytes` or :class:`bytearray`. The
+ input encoding should be UTF-8, UTF-16 or UTF-32.
+
+
Encoders and Decoders
---------------------
-.. class:: JSONDecoder(object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
+.. class:: JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
Simple JSON decoder.
@@ -344,6 +356,9 @@ Encoders and Decoders
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: decode(s)
Return the Python representation of *s* (a :class:`str` instance
@@ -362,7 +377,7 @@ Encoders and Decoders
extraneous data at the end.
-.. class:: JSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
+.. class:: JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Extensible JSON encoder for Python data structures.
@@ -443,6 +458,9 @@ Encoders and Decoders
the object or raise a :exc:`TypeError`. If not specified, :exc:`TypeError`
is raised.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: default(o)