https://www.bram.us/2022/01/11/yaml-the-norway-problem/ Skip to content Bram.us A rather geeky/technical weblog, est. 2001, by Bramus * Blog + Blog + All Posts + Original Content + Elsewhere * Talks * About * RSS + RSS + All Posts + Original Content Only + Elsewhere Only * Search * + Back YAML: The Norway Problem January 11, 2022April 8, 2023 2 Comments on YAML: The Norway Problem [yaml-e1641935644383-560x194] Earlier this week, Haroen Viaene posted this tweet about YAML: worst part of yaml: https://yaml.org/type/bool.html -- Haroen Viaene (@haroenv) January 10, 2022 The linked-to page contains the documentation on what defines a boolean in YAML, and details that it can be parsed using this regex: y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF ~ The reason to why this is problematic in some cases, is "The Norway Problem" YAML has: when you abbreviate Norway to its ISO 3166-1 ALPHA-2 form NO, YAML will return false when parsing it: countries: - GB - IE - FR - DE - NO >>> from pyyaml import load >>> load(the_configuration) {'countries': ['GB', 'IE', 'FR', 'DE', False]} The solution is to either escape these values in double quotes, or to use a library -- such as StrictYAML for Python -- that won't convert NO to False. ~ Other problematic values in YAML are version numbers that end in .0 and a lastname such as Null. By default these get converted to numbers or NULL respectively. The Norway Problem - StrictYAML - Posted byBramus!January 11, 2022April 8, 2023Posted inElsewhereTags: link, yaml Published by Bramus! Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more ...) View more posts Post navigation Previous Post Previous post: Don't Fight the Cascade, Control It! Next Post Next post: Customize the Password Hide/Reveal Button in Microsoft Edge Join the Conversation 1. [3c98114] 2. [c47bf5e] 2 Comments 1. [3c98114]Steve says: March 25, 2023 at 10:08 am ISO 3116 is about magnesium and magnesium alloys; I think you mean ISO 3166. Reply 1. [c47bf5e]Bramus! says: April 8, 2023 at 11:12 am Hahaha, great catch! Reply Leave a comment Cancel reply Your email address will not be published. Required fields are marked * [ ] [ ] [ ] [ ] Comment * [ ] Name * [ ] Email * [ ] Website [ ] [ ] Notify me of followup comments via e-mail. You can also subscribe without commenting. [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] This site uses Akismet to reduce spam. Learn how your comment data is processed. About Bram.us Bram.us is the technical/geeky weblog of Bramus Van Damme, a Freelance Web Developer from Belgium. Main topics are web related technologies (CSS, JS, PHP, ...), along with other geeky things (robots, space, ...) and personal interests (cartography, music, movies, ...). More ... Stay up-to-date To follow bram.us you can: * Subscribe to bram.us via RSS * Follow @bramusblog on Twitter * Give bram.us a like on Facebook Next to his ramblings here, you may also follow @bramus himself on Twitter or on Mastodon. Archives Archives [Select Month ] Search Search for: [ ] [Search] Bram.us, Proudly powered by WordPress.