Hacker News new | ask | show | jobs
by Kwpolska 556 days ago
The problem is using JSON as a file format in the first place. It’s not designed for humans to edit. (Then again, it’s better than the Norway-sceptic YAML.)
3 comments

I disagree. At least in an ought vs is sense: it's entirely the kind of format that I would create as an editable format. As witnessed by the fact that my workmates and I did create very nearly JSON previously as a file format in the 90s (but for C code programs)
For a very narrow target audience (programmers), JSON is fine. If you want the file to be edited by anyone else, JSON is pain.
What example(s) of file format would you say are designed for humans to edit and still represent the kind of structured contents that json does?
TOML, extensions of json like json5 and hjson, a bunch of lesser known formats for nested structures like NestedText, UCL, kdl, Eno,sdlang, eldf, etc.

Also languages with some progrommatic capabilities like cue, dhall, jsonnet, nickel etc.

Non of them are perfect, and some are less suitable for certain use cases than others. But IMO pretty much all of them are better for human editing than json, and in many cases yaml.

Any format that:

- doesn't require to quote everything

- has lists/dictionaries

- uses indentation and new lines instead of commas and brackets

- doesn't have 1000 unnecessary features like YAML

Also, you don't need all types from JSON.

> you don't need all types from JSON

JSON has a very minimal set of types and I regularly use all of them. I guess you could argue that integers and numbers could be combined, but I think that's it.

I can’t think of anything that is not painful in some way.
JSON with trailing comma support.
But it happens. 'npm install' will edit your json file, but so can I.

That said, I don't like it as a config file read/written by humans.