Merge pull request #4675 from tiesjan/2.1.x

Document serialization of Decimal in JSONEncoder
This commit is contained in:
David Lord 2022-07-06 05:33:05 -07:00 committed by GitHub
commit cafe68e1ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View file

@ -242,6 +242,7 @@ for easier customization. By default it handles some extra data types:
- :class:`datetime.datetime` and :class:`datetime.date` are serialized
to :rfc:`822` strings. This is the same as the HTTP date format.
- :class:`decimal.Decimal` is serialized to a string.
- :class:`uuid.UUID` is serialized to a string.
- :class:`dataclasses.dataclass` is passed to
:func:`dataclasses.asdict`.

View file

@ -23,6 +23,7 @@ class JSONEncoder(_json.JSONEncoder):
- :class:`datetime.datetime` and :class:`datetime.date` are
serialized to :rfc:`822` strings. This is the same as the HTTP
date format.
- :class:`decimal.Decimal` is serialized to a string.
- :class:`uuid.UUID` is serialized to a string.
- :class:`dataclasses.dataclass` is passed to
:func:`dataclasses.asdict`.