3 ms·
Ok but, just like the author of that article, you're just using the wrong datatype... You can easily get the desired behavior by quoting the strings: - yam
by angryzor 3y ago
Ok but, just like the author of that article, you're just using the wrong datatype... You can easily get the desired behavior by quoting the strings:
- yaml:
- '01'
- '08'
Complaining about this is like complaining that
{ json: [01, 08] }
will be interpreted as [1, 8] in json... It's not a problem with the tool, it's a user error.
- roryokane 3y agoIt’s not just user error – it’s a problem with the YAML format and culture. The YAML format allows most strings to be written without quotes. And YAML culture, as communicated through most YAML snippets in documentation and YAML files in the wild, is to take advantage of this by only adding quotes when necessary. That makes certain categories of user error much more likely. Someone might write `09` and confirm it’s a string, then change `9` to `7` and not notice that their string has turned into a number. The JSON format avoids this problem because it requires that all strings be quoted. If you start with `["09", "08"]` and change one of the digits inside the quotes, the string will stay a string. In JSON, strings becoming not-strings – removal of quotes or addition of backslash escaping – is more obvious than in YAML.