From e9de4ca052dda8ad1b19da7fc383e5bfa170c266 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sat, 21 May 2016 13:37:16 +0100 Subject: [PATCH] Added note on YAML mappings as objects --- components/yaml/introduction.rst | 14 ++++++++++++++ components/yaml/yaml_format.rst | 2 ++ 2 files changed, 16 insertions(+) diff --git a/components/yaml/introduction.rst b/components/yaml/introduction.rst index c61b40fa0e4..9bb06327955 100644 --- a/components/yaml/introduction.rst +++ b/components/yaml/introduction.rst @@ -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 ` 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 ~~~~~~~~~~~~~~~~~~ diff --git a/components/yaml/yaml_format.rst b/components/yaml/yaml_format.rst index 0a776be2a70..2e9d24a95ef 100644 --- a/components/yaml/yaml_format.rst +++ b/components/yaml/yaml_format.rst @@ -165,6 +165,8 @@ YAML uses the ISO-8601 standard to express dates: # simple date 2002-12-14 +.. _yaml-format-collections: + Collections -----------