Skip to content

Commit

Permalink
minor #20510 [Yaml] feature #59315 Add compact nested mapping support…
Browse files Browse the repository at this point in the history
… to Dumper (gr8b)

This PR was squashed before being merged into the 7.3 branch.

Discussion
----------

[Yaml] feature #59315  Add compact nested mapping support to Dumper

Documentation update for YAML Dumper feature `Yaml::DUMP_COMPACT_NESTED_MAPPING`.

Commits
-------

12bb604 [Yaml] feature #59315  Add compact nested mapping support to Dumper
  • Loading branch information
javiereguiluz committed Jan 22, 2025
2 parents 26cbad4 + 12bb604 commit 7261af2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions components/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,34 @@ By default, digit-only array keys are dumped as integers. You can use the
$dumped = Yaml::dump([200 => 'foo'], 2, 4, Yaml::DUMP_NUMERIC_KEY_AS_STRING);
// '200': foo

Dumping Collection of Maps
~~~~~~~~~~~~~~~~~~~~~~~~~~

By default, the collection of maps uses a hyphen on a separate line as a delimiter.
To use the delimiter line as part of the map dump, use the ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag.

Dump without flag set:

.. code-block:: yaml
planets:
-
name: Mercury
distance: 57910000
-
name: Jupiter
distance: 778500000
Dump with ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag set:

.. code-block:: yaml
planets:
- name: Mercury
distance: 57910000
- name: Jupiter
distance: 778500000
Syntax Validation
~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 7261af2

Please sign in to comment.