If you want something that's easier to edit for config files, you can use YAML.
If you want something that's easier to edit for config files, you can use YAML.
And.. yeah, for human processing/reading/writing, ignoring trailing commas and having comment does improve JSON IMO.
I don't know why JSON is so strict in fact. Virtually everyone forgets to NOT have the last comma of a list all the time.
Now then again HJSON is +1 standard and incompatible with JSON so im not sure how that'll take off.
JSON:
{ 'one': 1, 'two': 2 }
YAML: one: 1
two: 2I like the idea of a slightly simpler JSON but still keeping just the primitive data types yet not being able to say, include arbitrary files into the document.
They just want to be able to write sloppy JSON and have code handle all the strict requirements of real JSON.
Some people are pushing for TOML as an alternative but I'm not sure if that's going to happen.
Its for when you need a quick config file, and you think "Gosh, I wish I could just put some sloppy JSON/Python-like code in here, with a few comments.", and you don't want to use XML, INI, or YAML, or roll your own format.
I guess most people here are in the web development business. Which is fine, but I am not currently. I don't need JSON for what JSON is made for, but I often need something almost like JSON for my use cases.
You know what's annoying? Having to remember a dozen-odd JSON-but-not-really config file syntaxes instead of just JSON.
That's why YAML is out of the question for me. But JSON is too restricted to write it manually (no trailing commas, no comments, no round-trip-safety). What I'd ideally like is to take this Python/JS5 file (differ only in the comment indicator # vs //)
# this is an important comment
obj = {'hello': 'world',
'list': [1,2,3,4,5,]}
...
from configfile import obj
and to turn it into a safe // this is an important comment
{'hello': 'world',
'list': [1,2,3,4,5,]}
...
obj = parser.loads("configfile.cfg")
It's not that I don't like JSON. Its just that I have a different requirements. When I need JSON, I use JSON. When I need easily editable config files that look like Python or JS (which I can easily remember), I use something like HJSON. {
"configOption": {
"c": "This option is configurable.",
"val": 42
}
}
And now, the comment is round-trip-safe and exists!It's a human friendly (to some. It's ambiguous, so I don't think it's very friendly) , but it's not JSON and doesn't offer any of the advantages of JSON.