Skip to content

Why I Love JSON

ilovejson.com
15 pointszpoley8 comments
On HN

Comments

I love JSON because I remember how painful it was to use XML for the things I now do with JSON. It's a breath of fresh air.

Having used both in admittedly elementary contexts this is the #1 reason, easily

I love JSON because there is a straightforward mapping from JSON to the data types supported by many programming languages.

Agreed. Even if the syntax is wildly different, the structure is similar.

This is where XML gets annoying. Sure, it does make sense in certain situations, but it quickly gets hard to map all the attributes and child nodes into a nice object.

Its easier to drill down to what you need without having to mess with arrays or attribute hashes or retrieving contents. (Retrieving contents is the worst part. Sure CDATA would theoretically help, but what do I do when the API I'm using ignores it? Parsing linebreaks, spaces, and empty tags becomes a hassle!)

I love JSON because it provides for one and only one correct way to serialize a particular data structure. With XML I always have to decide whether to use an attribute vs. content vs. child node for a particular piece of data. There's an enormous "impedance mismatch" between XML and pretty much any programming language, whereas JSON just feels natural.

I love s-expressions.

My other car is a car.

Damn you CDR-coding! selling out our jokes for petty cache.

I love JSON because it's a strict subset of YAML.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.