Evolving article. Work in progress.
Gist : - Prefer to use json for configurations. Yaml tries to be too clever with non-string datatypes, and ruins things.
Be paranoid and untrustworthy towards the yaml/json config parsers. Use strings in all configurations. When applications read these configurations, make the language parse the string into the intended datatype.
This "use strings everywhere" goes against conventions. But I've seen enough rampant idiocy and mistakes in software to not trust conventions. I now have a fundamental distrust on software correctness.
Yaml issues
If the value is double quoted (string), the yaml parser will leave it as it is.
If the value is not double qupted, the yaml parser will try to convert the value into one if its supported datatypes. If the value cannot be represented in any datatype, the parser will convert it to string.
Booleans can be defined by too many values
https://yaml.org/type/bool.html
Following strings are resolved as boolean True
:
- y, Y
- yes, YES, YEs
- true, True, TRUE
- off, Off, OFF
Following strings are resolved as boolean False
:
- n, N
- no, No, NO
- false, False, FALSE
- off, Off, OFF
Those are just too many values.
Imagine having a configuration
countryCode: 'NO' # code for Norway
The yaml parser will interpret it as:
countryCode: False
Which is an idiotic outcome
Numbers with exponents can have different value in different versions
Depending on the version used by your library, an integer with exponents can either be resolved as a string, or as an integer
Consider this:
multiplier: 1e3
- Some versions will resolve it as as string
multiplier: "1e3"
- Some versions will resolve it as as a number:
multiplier: 1000"