5 ms·
I’ve often heard this (YAML is a superset of JSON) but never looked into the details. According to https://yaml.org/spec/1.2.2/ https://yaml.org/spec/1.2.2/, Y
by guitarsteve 5y ago
I’ve often heard this (YAML is a superset of JSON) but never looked into the details.
According to https://yaml.org/spec/1.2.2/ https://yaml.org/spec/1.2.2/, YAML 1.2 (from 2009) is a strict superset of JSON. Earlier versions were an _almost_ superset. Hence the confusion in this thread. It depends on the version…
- DHowett 5y agoThe JSON::XS documentation linked above reports that YAML 1.2 is not a strict superset of JSON: > Addendum/2009: the YAML 1.2 spec is still incompatible with JSON The author also details their issues in, ah, getting some of the authors of the YAML specification to agree.
- kelnos 5y agoCPAN link provided by the parent says 1.2 still isn't a superset: > Addendum/2009: the YAML 1.2 spec is still incompatible with JSON, even though the incompatibilities have been documented (and are known to Brian) for many years and the spec makes explicit claims that YAML is a superset of JSON. It would be so easy to fix, but apparently, bullying people and corrupting userdata is so much easier.
- terom 5y agoAre these documented YAML 1.2 JSON incompatibilities listed / linked to somewhere? I assume these are something related to non-ascii string encoding / escapes?
- guelo 5y agoThey are listed in that same CPAN link "Please note that YAML has hardcoded limits on (simple) object key lengths that JSON doesn't have and also has different and incompatible unicode character escape syntax... YAML also does not allow \/ sequences in strings"
- peterburkimsher 5y agoIn the beginning was the SGML. Then we said it's too verbose. We named some subsets XML, HTML, XLSX. Then we said it's still too long. So we named some subsets Markdown, and YML. Then we said it's still too long, and made JSON. What's wrong with subsets? Ambiguity in naming things. https://martinfowler.com/bliki/TwoHardThings.html https://martinfowler.com/bliki/TwoHardThings.html Is JSON the same as YML? NO. Norwegian? https://news.ycombinator.com/item?id=26671136 https://news.ycombinator.com/item?id=26671136
- dudeinjapan 5y agoFirst they came for the angle brackets. And I did not speak out. Because I did not use XML...
- peterburkimsher 5y agoYou didn't use XML? But We use XML to read the comments here on this HTML web page. But I came for the angle brackets. Because I < We, eternally.
- coldtea 5y agoWell, Markdown and YML and JSON are not subsets of SGML, nobody claims they are, and nobody intented them as such. So there's that.
- tannhaeuser 5y agoWhile indeed neither markdown, much less JSON syntax has been intended as an SGML app, that doesn't stop SGML from parsing JSON, markdown, and other custom Wiki syntax using SHORTREF [1] ;) In fact, the original markdown language is specified as a mapping to HTML angle-bracket markup (with HTML also an SGML vocabulary), and thus it's quite natural to express that mapping using SGML SHORTREF, even though only a subset can be expressed. [1]: https://www.balisage.net/Proceedings/vol17/html/Walsh01/BalisageVol17-Walsh01.html https://www.balisage.net/Proceedings/vol17/html/Walsh01/Bali... [2]: https://daringfireball.net/projects/markdown/ https://daringfireball.net/projects/markdown/
- vbezhenar 5y agoI just checked YAML 1.2 and it seems that 1024 limit length on keys still in spec (https://yaml.org/spec/1.2.2/ https://yaml.org/spec/1.2.2/, ctrl+f, 1024). So any JSON with long keys is not compatible with YAML.
- forty 5y agoTo be fair, any JSON implentation is going to have a practical limit on the key size, it's just a bit more random and harder to figure out :)
- hvdijk 5y agoIf you mean limited by available memory, then sure but that does not apply just to key size. If you mean something else, could you elaborate?
- 01acheru 5y agoI guess it is about different implementations of some not properly formalized parts of the JSON spec. There was also an article here some time ago but I cannot find it right now.
- forty 5y agoI assume JSON implementations have a some limit on the key size (or on the whole document which limits the key size), hopefully far below the available memory.
- hvdijk 5y agoI assume and hope that they do not, if there is no rule stating that they are invalid. There are valid reasons for JSON to massive keys. A simple one: depending on the programming language and libraries used, an unordered array ["a","b","c"] might be better mapped as a dictionary {"a":1,"b":1,"c":1}. Now all of your keys are semantically values, and any limit imposed on keys only makes sense if the same limit is also imposed on values.