summaryrefslogtreecommitdiffstats
path: root/Lib/json/__init__.py
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-04-03 03:39:47 (GMT)
committerGitHub <noreply@github.com>2018-04-03 03:39:47 (GMT)
commit629338f1404ea9cd75e4fb0389a2fbe1b589de43 (patch)
tree228b72a6402a785a70ceab1ba94049634e07ea38 /Lib/json/__init__.py
parentbadb894bbbb8aaa8b669c4a6f675a0bc7d98e188 (diff)
downloadcpython-629338f1404ea9cd75e4fb0389a2fbe1b589de43.zip
cpython-629338f1404ea9cd75e4fb0389a2fbe1b589de43.tar.gz
cpython-629338f1404ea9cd75e4fb0389a2fbe1b589de43.tar.bz2
bpo-32360: Remove object_pairs_hook=OrderedDict examples (GH-5001)
Diffstat (limited to 'Lib/json/__init__.py')
-rw-r--r--Lib/json/__init__.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index a566009..3bb4490 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -28,8 +28,7 @@ Encoding basic Python object hierarchies::
Compact encoding::
>>> import json
- >>> from collections import OrderedDict
- >>> mydict = OrderedDict([('4', 5), ('6', 7)])
+ >>> mydict = {'4': 5, '6': 7}
>>> json.dumps([1,2,3,mydict], separators=(',', ':'))
'[1,2,3,{"4":5,"6":7}]'
@@ -285,14 +284,11 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
``object_pairs_hook`` is an optional function that will be called with the
result of any object literal decoded with an ordered list of pairs. The
return value of ``object_pairs_hook`` will be used instead of the ``dict``.
- This feature can be used to implement custom decoders that rely on the
- order that the key and value pairs are decoded (for example,
- collections.OrderedDict will remember the order of insertion). If
- ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
+ This feature can be used to implement custom decoders. If ``object_hook``
+ is also defined, the ``object_pairs_hook`` takes priority.
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``JSONDecoder`` is used.
-
"""
return loads(fp.read(),
cls=cls, object_hook=object_hook,
@@ -313,10 +309,8 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
``object_pairs_hook`` is an optional function that will be called with the
result of any object literal decoded with an ordered list of pairs. The
return value of ``object_pairs_hook`` will be used instead of the ``dict``.
- This feature can be used to implement custom decoders that rely on the
- order that the key and value pairs are decoded (for example,
- collections.OrderedDict will remember the order of insertion). If
- ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
+ This feature can be used to implement custom decoders. If ``object_hook``
+ is also defined, the ``object_pairs_hook`` takes priority.
``parse_float``, if specified, will be called with the string
of every JSON float to be decoded. By default this is equivalent to
@@ -337,7 +331,6 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
kwarg; otherwise ``JSONDecoder`` is used.
The ``encoding`` argument is ignored and deprecated.
-
"""
if isinstance(s, str):
if s.startswith('\ufeff'):