Skip to content

Commit 9dfcb90

Browse files
committed
Document serialization of Decimal in JSONEncoder
The Flask JSONEncoder serializes Decimal types to strings, but this behavior is missing from the docs. The docs are updated accordingly.
1 parent e4c4fd5 commit 9dfcb90

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ for easier customization. By default it handles some extra data types:
242242

243243
- :class:`datetime.datetime` and :class:`datetime.date` are serialized
244244
to :rfc:`822` strings. This is the same as the HTTP date format.
245+
- :class:`decimal.Decimal` is serialized to a string.
245246
- :class:`uuid.UUID` is serialized to a string.
246247
- :class:`dataclasses.dataclass` is passed to
247248
:func:`dataclasses.asdict`.

src/flask/json/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class JSONEncoder(_json.JSONEncoder):
2323
- :class:`datetime.datetime` and :class:`datetime.date` are
2424
serialized to :rfc:`822` strings. This is the same as the HTTP
2525
date format.
26+
- :class:`decimal.Decimal` is serialized to a string.
2627
- :class:`uuid.UUID` is serialized to a string.
2728
- :class:`dataclasses.dataclass` is passed to
2829
:func:`dataclasses.asdict`.

0 commit comments

Comments
 (0)