Skip to content

Explained the explicit typing in YAML documents #8200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions components/yaml/yaml_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,22 @@ Comments can be added in YAML by prefixing them with a hash mark (``#``):
Comments are simply ignored by the YAML parser and do not need to be
indented according to the current level of nesting in a collection.

Explicit Typing
---------------

The YAML specification defines some tags to set the type of any data explicitly:

.. code-block:: yaml

data:
# this value is parsed as a float number (it will be 3.0 instead of 3)
price: !!float 3

# this value is parsed as binary data encoded in base64
picture: !!binary |
R0lGODlhDAAMAIQAAP//9/X
17unp5WZmZgAAAOfn515eXv
Pz7Y6OjuDg4J+fn5OTk6enp
56enmleECcgggoBADs=

.. _YAML: http://yaml.org/