Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I read and write json manually almost every day. I haven't bothered to insert json5 in our pipelines for various reasons, but I sure wish it was the default.

The interesting question I think is, why do you think json is so used in that capacity despite not being meant for it? Why YAML, despite being so widespread, hasn't swept json away for those purposes? (let's for a moment ignore that YAML can go REALLY nuts, and think only of the simplest version of it)



I used to think YAML would be great for that sort of thing. Now, having dealt with some large YAML files, I understand at least a couple of reasons why people don't like it for that. Things that are invisible when visually looking at a file, and not really detectable by IDEs or linters or anything (because they would have to assume your intent).

In a small file, semantic indentation is beautiful. In a large file where you have to scroll and scroll to find out where you are, it's a pain. And perhaps importantly - can't be autoformatted. Your IDE doesn't know what indentation level you intended, and without braces/brackets to tell it, it can't detect errors.

There's parsing automagic wackiness if you're not careful (the famous example: country abbreviation NO for Norway becomes FALSE).

The nice feature of references is almost never actually used in practice. An incorrect or circular reference can look fine but badly break things.

Yaml typing is application (and version) dependent so not really useful.

There's more, but basically JSON, though simpler and uglier, prevents all of those. You can, and pretty much have to, use an alternative 'safe YAML' parser, but even that doesn't solve some of the problems.


References are used quite a bit. Look at OpenAPI; they're critical to that effort.


> let's for a moment ignore that YAML can go REALLY nuts, and think only of the simplest version of it

But we can't ignore it… we have to validate and make sure it isn't going too nuts. And we will probably fail at that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: