Skip to content

Commit ce28629

Browse files
94nonijaviereguiluz
authored andcommitted
[Serializer] (re)document PRESERVE_EMPTY_OBJECTS
1 parent ccd1137 commit ce28629

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: serializer.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,13 @@ to ``true``::
15711571
]);
15721572
// $jsonContent contains {"name":"Jane Doe"}
15731573

1574+
Preserving Empty Objetcs
1575+
~~~~~~~~~~~~~~~~~~~~~~~~
1576+
1577+
By default, the Serializer will transform an empty array to `[]`.
1578+
You can change this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS`` context option
1579+
to ``true``, when the value is `\ArrayObject()` the serialization would be `{}`.
1580+
15741581
Handling Uninitialized Properties
15751582
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15761583

0 commit comments

Comments
 (0)