Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ Customizing JSON object decoding::
>>> import decimal
>>> json.loads('1.1', parse_float=decimal.Decimal)
Decimal('1.1')
>>> json.loads('{"name": "point", "coords": [[1, 2], [3, 4]]}',
... array_hook=tuple) # doctest: +SKIP
{'name': 'point', 'coords': ((1, 2), (3, 4))}
>>> json.loads('{"name": "point", "coords": [1, 2]}',
... object_pairs_hook=frozendict, array_hook=tuple) # doctest: +SKIP
frozendict({'name': 'point', 'coords': (1, 2)})

Extending :class:`JSONEncoder`::

Expand Down Expand Up @@ -303,7 +309,7 @@ Basic Usage

:param array_hook:
If set, a function that is called with the result of
any JSON array literal decoded with as a Python list.
any JSON array literal decoded as a Python list.
The return value of this function will be used
instead of the :class:`list`.
This feature can be used to implement custom decoders.
Expand Down
2 changes: 1 addition & 1 deletion Lib/json/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def __init__(self, *, object_hook=None, parse_float=None,
be used along ``object_pairs_hook`` to customize the resulting data
structure - for example, by setting that to ``frozendict`` and
``array_hook`` to ``tuple``, one can get a deep immutable data
structute from any JSON data.
structure from any JSON data.
``parse_float``, if specified, will be called with the string
of every JSON float to be decoded. By default this is equivalent to
Expand Down
Loading