From 369ea13ea891df848615e629bd35e3f539b3eb94 Mon Sep 17 00:00:00 2001 From: Gauthier Gilles Date: Tue, 17 Dec 2019 09:27:31 +0100 Subject: [PATCH] add caution for datetime object --- serializer.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/serializer.rst b/serializer.rst index b1e64881831..31c47e607dc 100644 --- a/serializer.rst +++ b/serializer.rst @@ -115,6 +115,12 @@ Custom normalizers and/or encoders can also be loaded by tagging them as :ref:`serializer.encoder `. It's also possible to set the priority of the tag in order to decide the matching order. +.. caution:: + + Always make sure to load the ``DateTimeNormalizer`` when serializing the + ``DateTime`` or ``DateTimeImmutable`` classes to avoid excessive memory + usage and exposing internal details. + Here is an example on how to load the :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`, a faster alternative to the `ObjectNormalizer` when data objects always use