Hacker News new | ask | show | jobs
by Lexarius 1608 days ago
That's an old YAML 1.1 behavior. It was removed in 1.2 (in 2009), though some implementations (looking at you, pyyaml) are still on 1.1.
2 comments

Guess what was not removed?

    1 : 1,0
    2: 01
    3: 1.0
    4: 1O
    5: 0b1
    6: 0x1
    7: 0i1
    8: hey,
    8.0: oh,
    version: [3.1, "3.1", 3.10, "3.10"]

Gives you:

    {
    "1": "1,0", 
    "2": 1, 
    "3": 1.0, 
    "4": "1O", 
    "5": 1, 
    "6": 1, 
    "7": "0i1", 
    "8": "oh,", 
    "version": [
        3.1, 
        "3.1", 
        3.1, 
        "3.10"
    ]
    }
YAML turns raw literals into strings, except when the string matches a certain format. Then it may turn it into other things, like int or float, and you better know all the rules by heart and be attentive. And not introduce any typo, which of course no human ever does.
That's why yaml is a format for computer and json a format for humans
And that's also why everybody use JSON to configure CI, and use YAML for REST API.
So YAML is fine with breaking compatibility in minor version bumps?
Semver was not yet common practice when 1.2 was released.
https://yaml.org/spec/1.2.0/ says 2009

Not breaking backwards compatibility in a minor version bump of a data format was absolutely common sense in 2009.

semver.org -- which did an amazing job popularizing this idea -- did not yet have its webpage up in July 2009 (archive.org has it in December)