3 ms·
How is YAML a superset of JSON? never heard that claim before.
by TedDoesntTalk 5y ago
How is YAML a superset of JSON? never heard that claim before.
- BiteCode_dev 5y agoAny valid json can be parsed by any 1.2 yaml parser. That's how it gained popularity in the first place: you didn't have to migrate. Like ascii and utf8.
- riffraff 5y agoWhen YAML came out there was no large JSON usage to migrate from, the incumbent in configuration was "human readable serialization" was XML.
- rudian 5y agoYou can turn any piece of a YAML into a JSON object and it will be read just as well. This YAML: user: name: Ted is equivalent to this YAML: user: {"name": "Ted"} which is equivalent to this YAML/JSON: {"user": {"name": "Ted"}}
- Spivak 5y agoWhile true, this is what being a supperset means. What it means is that any JSON document is, without modification, valid YAML document and can be read with a YAML parser.
- erik_seaberg 5y agoYAML supports tagged nodes and multiple documents in a stream, which can’t be represented in standard JSON. (You could make up conventions, but only your parser would support them.)
- NoThisIsMe 5y agoIt just is: Any valid JSON is valid YAML with the same semantics. It was intentionally designed that way (though not from the start iirc). Basically take JSON, make quotes optional for strings and make curly brackets optional if the object is indented properly, and boom you've got (something like) YAML.
- yuuu 5y agoIf all JSON is YAML but not all YAML is JSON, then YAML is a superset of JSON.