The Norway Problem in YAML

orsenthil1 pts0 comments

The Norway Problem in Yaml | Senthil Kumaran

Skip to main content

Norway's ISO country code is NO. Under the YAML 1.1 spec, unquoted no (case-insensitive, along with yes, on, off, y, n, true, false) is treated as a boolean and not a string.

You can see the problem here.

~ cat test.yaml<br>countries:<br>- NO<br>- SE<br>- NL<br>- IN<br>- US<br>- SG

~ python

>>> import yaml<br>>>> with open("test.yaml") as f:<br>... data = yaml.safe_load(f)<br>...<br>>>> print(data)<br>{'countries': [False, 'SE', 'NL', 'IN', 'US', 'SG']}

This and other things are fixed Kubernetes Flavored Yaml. Which has minimal syntax like, all flow style syntax with {} for objects and [] for arrays. All string values must be double-quoted.

yaml norway problem false string test

Related Articles