logoalt Hacker News

bearjaws12/09/20245 repliesview on HN

The whole reason JSON rules the world is because it's brutally simple.

We already have 5+ replacements that are far more robust(XML, YML) and IMO they are not great replacements for JSON.

Why? Because you can't trust most people with anything more complicated than JSON.

I shutter at some of the SOAP / XML I have seen and whenever you enable something more complicated inevitably someone comes up with a "clever" idea that ruins your day.


Replies

JoshTriplett12/09/2024

> The whole reason JSON rules the world is because it's brutally simple.

I don't think that's the primary reason. JSON is pervasive because it started out being trivially parseable by JavaScript going back to when people just evaluated it, even before browsers had ridiculously high-perfomance safe JSON parsers. All the other formats are still harder to work with from JavaScript.

If not for that, personally I'd advocate TOML, which is incredibly simple.

show 2 replies
Zamicol12/09/2024

We use JSON5 for two reasons:

1. Comments 2. Trailing commas

We don't use any other JSON5 features, which are primarily just that numbers may be encoded in hexadecimal and field names may have quotes elided.

We typically encode values with RFC 4648 base 64 URI canonical with padding truncated (b64ut) with values too large to be a JSON number, so hex isn't useful anyway. We haven't found that omitting field name quotes is a big deal.

show 1 reply
yencabulator12/09/2024

    is yaml robust: no
show 1 reply
layer812/09/2024

The only reason JSON got any traction is because it was a subset of client-side JavaScript and thus natively supported in the browser.

eterevsky12/09/2024

To be precise, JSON was a replacement for XML, not the other way around. And the problem with XML was that it's way to verbose and difficult to write by hand, so it's exactly the opposite of the direction YAML/JSON5/... are taking.

show 1 reply