Skip to content

Commit 63ea659

Browse files
committed
Added a lot more cases for enclosing strings with quotes
1 parent ce6e3eb commit 63ea659

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

components/yaml/yaml_format.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ escaped with double quotes:
117117
* ``\L``
118118
* ``\P``
119119

120+
Finally, there are other cases when the strings must be quoted, no matter if
121+
using single or double quotes:
122+
123+
* when the string is ``true`` or ``false`` (otherwise, it would be treated as a
124+
boolean value);
125+
* when the string is ``null`` or ``~`` (otherwise, it would be considered as a
126+
``null`` value);
127+
* when the string looks like a number, such as integers (e.g. ``2``, ``14``, etc.),
128+
floats (e.g. ``2.6``, ``14.9``) and exponential numbers (e.g. ``12e7``, etc.)
129+
(otherwise, it would be treated as a numeric value);
130+
* when the string looks like a date (e.g. ``2014-12-31``) (otherwise it would be
131+
automatically converted into a Unix timestamp).
132+
120133
When a string contains line breaks, you can use the literal style, indicated
121134
by the pipe (``|``), to indicate that the string will span several lines. In
122135
literals, newlines are preserved:

0 commit comments

Comments
 (0)