These are completely different serialization formats.
These are completely different serialization formats.
But the yaml docs said it’s accidental
«The YAML 1.18 specification was published in 2005. Around this time, the developers became aware of JSON9. By sheer coincidence, JSON was almost a complete subset of YAML (both syntactically and semantically).»
The SAP article definitely states it, that's the first time I have seen it described that way.
> YAML can therefore be viewed as a natural superset of JSON, offering improved human readability and a more complete information model.
It's one of those beliefs that seems like it should be true, but isn't for obscure technical reasons.
It appears to still be true in at least Ruby and Python, which are probably the two most popular languages to write YAML-consuming programs in:
$ irb -v
irb 1.3.5 (2021-04-03)
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML.load '{"a": 1e2}'
=> {"a"=>"1e2"}
irb(main):003:0>
and $ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.safe_load('{"a": 1e2}')
{'a': '1e2'}
>>>
-- > The spec specifies it should assume 1.2 and 1.1 should be opt-in.
The spec for 1.2 says that, but that's the reason parsers can't upgrade to 1.2, because changing the default version will cause backwards-incompatible parsing changes. Without the version directive there's no way for the parser to know which version was intended, so it defaults to 1.1, so people writing YAML will write YAML 1.1 documents, because that's what the parsers expect.The only way YAML 1.2 is going to displace older versions is in a greenfield ecosystem that has all its tools using YAML 1.2 from the beginning, but that requires an author who both (1) cares a lot about parser correctness, and (2) wants to use YAML as a config syntax, which isn't a large population.