5 ms·
YAML can go off and die in a fire... especially because it cannot transfer the data type, which JSON can: you have either an integer, a float or a string. Also
by mschuster91 9y ago
YAML can go off and die in a fire... especially because it cannot transfer the data type, which JSON can: you have either an integer, a float or a string. Also some libraries want the values escaped, some not, some barf on non-alphanumeric keys... JSON is pretty much standardized across the board.
- nly 9y ago> you have either an integer, a float or a string. JSON doesn't have "integers" and "floats", it has "numbers" which are are expressed in decimal scientific notation. There's no guarantee an implementation will let you distinguish what was parsed, and the numerical precision and range of interoperable JSON is undefined. The bottom line is JSON is a risky proposition for financial or scientific data exchange. And before you say JSON numbers are de-facto IEEE754 doubles, bare in mind that most JSON implementations can't roundtrip them properly.[0] A symptom of everybody wanting to write a toy implementation. [0] https://rawgit.com/miloyip/nativejson-benchmark/master/sample/conformance.html https://rawgit.com/miloyip/nativejson-benchmark/master/sampl...
- callumlocke 9y agoI use YAML all the time (for config) and the things you mention have caused no more than one minute's frustration in my life. JSON is great for serialisation, YAML for little config files that need frequent hand-editing during development.
- NateDad 9y agoYaml is terrible. The fact that there are so many optional and different ways to format things and the fact that it has significant white space means it's horrible to hand edit. I'd much rather hand edit json. At least it won't care if I accidentally use a tab instead of two spaces. But of course toml is superior to both because it has comments and no significant white space and the comma at the end of lists is optional.
- sebcat 9y agoHere are some examples: https://github.com/cblp/yaml-sucks https://github.com/cblp/yaml-sucks TBH, common JSON implementations have their problems too. Integer size and integer/float (de-)serialization tend to be somewhat interesting at times. I've even seen implementations serializing JavaScript objects as JSON (e.g., {foo: 2} instead of {"foo": 2})