Skip to content

[Serializer] fix(serializer): missing empty_array_as_object in example #16977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ resources. This context is passed to all normalizers. For example:
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer` uses
``datetime_format`` key as date time format;
* :class:`Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer`
uses ``empty_iterable_as_object`` to represent empty objects as ``{}`` instead
uses ``preserve_empty_objects`` to represent empty objects as ``{}`` instead
of ``[]`` in JSON.
* :class:`Symfony\\Component\\Serializer\\Serializer`
uses ``empty_array_as_object`` to represent empty arrays as ``{}`` instead
of ``[]`` in JSON.

.. versionadded:: 5.4

The usage of the ``empty_array_as_object`` option by default in the
The usage of the ``empty_array_as_object`` option in the
Serializer was introduced in Symfony 5.4.

You can pass the context as follows::
Expand Down