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

Json5, although not widely adopted. Has // comments and /* block comments.

It also allows additional trailing , in lists. Something I hate but is a great feature if you use a macro system on top of it. (Like jinja2).



I've gotten bit by trailing commas enough times (both manual edits and writing generators) that I absolutely expect any reasonable syntax to tolerate them. It's just so much easier and more consistent to tolerate them.


That's what Clojure got right. Comma is whitespace. When you print a datastructure, it has commas. But they don't effect reading of that structure. Its brilliant and practical.


As importantly, it reduces the noise in diffs when an item is added to a sequence.


You can use prefix separators for that. Haskell-style.


Doesn't that just push the problem to the other side of the list?


It does. However, it’s much more common to edit the end of a list, in my experience. Still, a syntax that is entirely uniform (like trailing commas) is preferable, in my opinion.


This is why I switched to leading commas.


JSON5 does, but most software just does plain and simple JSON. I haven't seen it used outside some Javascript webdev environments. The JSON5 docs also seem to be specifically targeting Javascript development.

If you're sticking to certain variants, you may as well use YAML, which supports JSON notation, as well as comments and various other improvements.


If you use python, there is an excellent json5 module. But true, it may not be as well supported by other languages.

I am not sure I may as well be using yaml. I don't like it for the multiple reasons in the OP and this thread.

If you are using python, I have found it to be quite easy to support both json5 and yaml, as well as converting between them for people who feel strongly about yaml. Not trivial but low effort.




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

Search: