News for hackers. Stuff that matters.
Re:The Norway Problem by mattmanser on Saturday April 03, 2021 @05:28AM (#26679524)
Never's a strong word, seems quite easy to understand why to me. You've got ease of use reasons, historical reasons like the mis-guided Robustness principle, etc.

And these sort of things happen time and time again.

And although officially JSON requires quoted strings, almost none of the parsers actually enforce that, and so you will find a huge amount of JSON out there that is not actually compliant with the official spec.

Just like browsers have huge hacks in them to handle misformed HTML.

Re:The Norway Problem by Safety1stClyde on Saturday April 03, 2021 @06:32AM (#26679843)
> And although officially JSON requires quoted strings, almost none of the parsers actually enforce that

What programming language? I'm not familiar with those parsers, the ones I know of very much do enforce quoted strings.

> you will find a huge amount of JSON out there that is not actually compliant with the official spec

The parsers I use all follow the current JSON RFC specification, and I've never encountered any JSON from APIs which they reject.

> Just like browsers have huge hacks in them to handle misformed HTML.

Web browsers do deal with a variety of things, not so much JSON parsers in my experience.

Re:The Norway Problem by Macha on Saturday April 03, 2021 @07:49AM (#26680254)
I think the point is that they accept more than the spec dictates - do your JSON parsers accept e.g. the vs code config file (JSON with comments) or JSON with unquoted keys?
Re:The Norway Problem by joelellis on Saturday April 03, 2021 @08:52AM (#26680654)
The most commonly used parsers only accept valid JSON - including the one included within most JS runtimes (JSON.stringify/parse). VSCode explicitly uses a `jsonc` parser, the only difference being that it strips comments before it parses the JSON. There's also such thing as `json5`, which has a few extra features inspired by ES5. None of them are unquoted strings. I've never come across anything JSON-like with unquoted strings other than YAML, and everything not entirely compliant with the spec has a different name.
Re:The Norway Problem by jokethrowaway on Saturday April 03, 2021 @08:30AM (#26680522)
Can you name a JSON parser which accept comments or unquoted keys?

I've never seen one

Re:The Norway Problem by cesarb on Saturday April 03, 2021 @11:55AM (#26682022)
IIRC, Gson accepts unquoted keys.