Skip to content

Commit 44d5b34

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Tweaks [Serializer] (re)document PRESERVE_EMPTY_OBJECTS
2 parents 344d8ba + 2a8ffcb commit 44d5b34

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
@@ -1877,6 +1877,14 @@ to ``true``::
18771877
]);
18781878
// $jsonContent contains {"name":"Jane Doe"}
18791879

1880+
Preserving Empty Objects
1881+
~~~~~~~~~~~~~~~~~~~~~~~~
1882+
1883+
By default, the Serializer transforms an empty array to ``[]``. You can change
1884+
this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS``
1885+
context option to ``true``. When the value is an instance of ``\ArrayObject()``,
1886+
the serialized data will be ``{}``.
1887+
18801888
Handling Uninitialized Properties
18811889
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18821890

0 commit comments

Comments
 (0)