Skip to content

Commit

Permalink
Merge pull request #4675 from tiesjan/2.1.x
Browse files Browse the repository at this point in the history
Document serialization of Decimal in JSONEncoder
  • Loading branch information
davidism authored Jul 6, 2022
2 parents e4c4fd5 + 9dfcb90 commit cafe68e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions src/flask/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit cafe68e

Please sign in to comment.