logoalt Hacker News

speedgoosetoday at 8:46 AM3 repliesview on HN

To answer seriously, my parent comment is a joke, JSON is a simpler format that maps better to most programming languages internal memory representations. Developers tend to prefer JSON’s simplicity over XML.


Replies

lelanthrantoday at 1:13 PM

> JSON is a simpler format that maps better to most programming languages internal memory representations.

That's not been my understanding of it - it maps better to most programming language representations of dictionaries and arrays, but not the internal memory representations.

berkestoday at 9:50 AM

> most programming languages internal memory representations

Often heard wrt JSON but incorrect. It maps to the primitive types in JavaScript. But almost all programming languages treat floats and integers different, make distinction between char and strings and many have some form of date/time. JSON has neither.

In that direction, XML is much closer since every node is a triple (name, value, attributes) so can have type info, json is a tuple. And Protobuf, while not popular, gets this completely right.

show 1 reply
einpoklumtoday at 11:29 AM

If this is intended for reading and writing by humans, then JSON doesn't cut it since you don't get comments (and perhaps also because of the weirdness of 64-bit floating-point values). Plus, XML is more "structurally nuanced". I suppose JSON is simpler to parse, but it's a trade-off of features, it's not like one is bad and the other is good.