Skip to content

Commit

Permalink
Added note on YAML mappings as objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech authored and xabbuh committed May 21, 2016
1 parent 330d40d commit e9de4ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions components/yaml/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ error if something goes wrong by adding the filename to the message.

.. _components-yaml-dump:

Objects for Mappings
....................

.. versionadded:: 2.7
Support for parsing mappings as objects was introduced in Symfony 2.6.

Yaml :ref:`mappings <yaml-format-collections>` are basically associative
arrays. You can instruct the parser to return mappings as objects (i.e.
``\stdClass`` instances) by setting the fourth argument to ``true``::

$object = Yaml::parse('{"foo": "bar"}', false, false, true);
echo get_class($object); // stdClass
echo $object->foo; // bar

Writing YAML Files
~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions components/yaml/yaml_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ YAML uses the ISO-8601 standard to express dates:
# simple date
2002-12-14
.. _yaml-format-collections:

Collections
-----------

Expand Down

0 comments on commit e9de4ca

Please sign in to comment.