-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,4 +300,25 @@ 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 string (it's not transformed into a DateTime) | ||
start_date: !str 2002-12-14 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created this issue: symfony/symfony#23607 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue closed. So let's keep it as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am still reluctant to document invalid YAML. I suggest to just remove it here and only document the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @xabbuh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough :D |
||
|
||
# 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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] to explicitly set [...]