YAML to JSON Conversion: The Gotchas That Break Your Config Files
YAML and JSON represent the same data structures: objects, arrays, strings, numbers, booleans, and null. Converting between them should be straightforward. In practice, YAML has several features an...

Source: DEV Community
YAML and JSON represent the same data structures: objects, arrays, strings, numbers, booleans, and null. Converting between them should be straightforward. In practice, YAML has several features and quirks that make the conversion surprisingly treacherous. The Norway problem YAML automatically interprets certain strings as non-string types: country: NO You expect: {"country": "NO"}. You get: {"country": false}. YAML interprets "NO" as a boolean false. Similarly, "YES" becomes true, "on" becomes true, "off" becomes false. This is the "Norway problem" -- representing the country code for Norway (NO) in YAML requires quoting: country: "NO". Other surprising type coercions: version: 1.0 # Becomes number 1, not string "1.0" version: 1.10 # Becomes number 1.1, not string "1.10" octal: 0777 # Becomes decimal 511 in YAML 1.1 date: 2024-01-15 # Becomes a Date object, not a string The version: 1.10 case is particularly dangerous. You expect the string "1.10" but get the number 1.1. In a version