Skip to content

Commit ab69163

Browse files
[Yaml] Add support for dumping null as an empty value by using the Yaml::DUMP_NULL_AS_EMPTY flag
1 parent 2ccc964 commit ab69163

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/yaml.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ you can dump them as ``~`` with the ``DUMP_NULL_AS_TILDE`` flag::
428428
$dumped = Yaml::dump(['foo' => null], 2, 4, Yaml::DUMP_NULL_AS_TILDE);
429429
// foo: ~
430430

431+
Another valid representation of the ``null`` value is an empty string. You can
432+
use the ``DUMP_NULL_AS_EMPTY`` flag to dump null values as empty strings::
433+
434+
$dumped = Yaml::dump(['foo' => null], 2, 4, Yaml::DUMP_NULL_AS_EMPTY);
435+
// foo:
436+
437+
.. versionadded:: 7.3
438+
439+
The ``DUMP_NULL_AS_EMPTY`` flag was introduced in Symfony 7.3.
440+
431441
Dumping Numeric Keys as Strings
432442
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
433443

0 commit comments

Comments
 (0)