by randomfool · 14y ago · 0 comments
I love JSON, but it does have it's issues.
Edit: I have been looking for reasonable configuration file formats for a while. Json actually has pretty bad human-readability at any scale because of its quoted key-values. Yaml is easily readable but when a user tries to change anything, things go to hell. The humble ini-file has won so far. It's limited and not fully standardized but it is human readable and human writable. I'd love see something better but human readability/writable is going trump all sorts of cleverness.
Edit2: From http://en.wikipedia.org/wiki/YAML "The specific number of spaces in the indentation is unimportant as long as parallel elements have the same left justification and the hierarchically nested elements are indented further."
Yeah, a user of your software is going to be able to understand when they mess up on that rule, riiiight. Screw Yaml.
https://github.com/triplefox/triad/blob/master/dev/com/ludam...
A "real-world" example https://github.com/triplefox/triad/blob/master/examples/Asse...
It seems "easy" but meaningful whitespace is a cluster-fck.
Tell that to everyone using Python. If your editor can't handle meaningful whitespace transparently, it sounds like you need a better editor.That said, I will not pretend for a second that this is a good idea. Crockford did the right thing.
You can always do this:
{
'people' : 10,
'desc': 'People who will attend'
}Which is why not intermingling comments with data makes sense.
>If you have to explain something you've probably written the JSON wrong.
You could say the same about code: "if you need to comment then your code isn't clear enough". In reality sometimes commenting code or data is helpful.