Skip to content
Myr

Document serialization of Decimal in JSONEncoder

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The Flask JSONEncoder serializes Decimal types to strings, but this behavior is missing from the docs. The docs are updated accordingly.

authored by Ties Jan Hefting · committed by Ties Jan Hefting · parent e4c4fd5 · Browse files · 2 files+2 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−0 removed

  • other:+2 added−0 removed

2 files+2 added−0 removed

modified:docs/api.rst+1 added
240 unmodified lines
241for easier customization. By default it handles some extra data types:242243- :class:`datetime.datetime` and :class:`datetime.date` are serialized244 to :rfc:`822` strings. This is the same as the HTTP date format.245- :class:`decimal.Decimal` is serialized to a string.246- :class:`uuid.UUID` is serialized to a string.247- :class:`dataclasses.dataclass` is passed to248 :func:`dataclasses.asdict`.249- :class:`~markupsafe.Markup` (or any object with a ``__html__``
525 unmodified lines
modified:src/flask/json/__init__.py+1 added
21 unmodified lines
2223 - :class:`datetime.datetime` and :class:`datetime.date` are24 serialized to :rfc:`822` strings. This is the same as the HTTP25 date format.26 - :class:`decimal.Decimal` is serialized to a string.27 - :class:`uuid.UUID` is serialized to a string.28 - :class:`dataclasses.dataclass` is passed to29 :func:`dataclasses.asdict`.30 - :class:`~markupsafe.Markup` (or any object with a ``__html__``
274 unmodified lines