Skip to content

Commit 2a8ffcb

Browse files
committed
Merge branch '6.4' into 7.2
* 6.4: Tweaks [Serializer] (re)document PRESERVE_EMPTY_OBJECTS
2 parents 97400af + e384239 commit 2a8ffcb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: serializer.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,14 @@ to ``true``::
18691869
]);
18701870
// $jsonContent contains {"name":"Jane Doe"}
18711871

1872+
Preserving Empty Objects
1873+
~~~~~~~~~~~~~~~~~~~~~~~~
1874+
1875+
By default, the Serializer transforms an empty array to ``[]``. You can change
1876+
this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS``
1877+
context option to ``true``. When the value is an instance of ``\ArrayObject()``,
1878+
the serialized data will be ``{}``.
1879+
18721880
Handling Uninitialized Properties
18731881
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18741882

0 commit comments

Comments
 (0)