8000 minor #8200 Explained the explicit typing in YAML documents (javiereg… · symfony/symfony-docs@861e72b · GitHub
[go: up one dir, main page]

Skip to content

Commit 861e72b

Browse files
committed
minor #8200 Explained the explicit typing in YAML documents (javiereguiluz)
This PR was squashed before being merged into the 2.7 branch (closes #8200). Discussion ---------- Explained the explicit typing in YAML documents I was going to fix #8173 but I couldn't find the explicit typing explanation anywhere, so I include it here. ----- When merging this into 3.4, the `!str` tag must be changed by `!!tag` and we must add this: ``` .. versionadded:: 3.4 The support of ``!!str`` tag was introduced in Symfony 3.4. In previous versions you needed to use the ``!str`` tag. ``` Commits ------- aa1b968 Explained the explicit typing in YAML documents
2 parents c2b2c17 + aa1b968 commit 861e72b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

components/yaml/yaml_format.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,22 @@ Comments can be added in YAML by prefixing them with a hash mark (``#``):
300300
Comments are simply ignored by the YAML parser and do not need to be
301301
indented according to the current level of nesting in a collection.
302302

303+
Explicit Typing
304+
---------------
305+
306+
The YAML specification defines some tags to set the type of any data explicitly:
307+
308+
.. code-block:: yaml
309+
310+
data:
311+
# this value is parsed as a float number (it will be 3.0 instead of 3)
312+
price: !!float 3
313+
314+
# this value is parsed as binary data encoded in base64
315+
picture: !!binary |
316+
R0lGODlhDAAMAIQAAP//9/X
317+
17unp5WZmZgAAAOfn515eXv
318+
Pz7Y6OjuDg4J+fn5OTk6enp
319+
56enmleECcgggoBADs=
320+
303321
.. _YAML: http://yaml.org/

0 commit comments

Comments
 (0)
0