Intimidating comment

Obviously, ignoring a problem / failing silently are bad strategies so we're left with throwing an exception.

There's no general behaviour that works well in all cases, so we opt for strictness in most cases. The JSON format has a lot of dead-space between elements and is space-insensitive in those regions, so there's no reason why you can't have single or multi-line comments there.

Thanks for the response and hopefully more people will change their minds as they read this conversation.

(making a parser was more of an exercise anyway :)That's like requiring all bicycles to have training wheels because some people can't ride bicycles.

So we can use this to create comments in the source JSON that will not be present in a parsed object representation. It was also never intended to be used for configuration files where comments would be needed. I hope your implementation gets known further - and perhaps even gets more popular than the original ;) I hope someone gets to implement it with Ruby as well.

@adelphus The language being well-defined is your own perspective or opinion.

For instance, take your programming language of choice: Just because some desired (but missing) feature isn't explicitly disallowed, doesn't mean that your compiler will magically recognize [email protected] Decent Think of a code reading a byte at a time, determining if it's valid syntax and if so, converting that input into tokens for another class to construct into objects.

A data format should prioritize usability over being idiot-proof.

- Douglas Crockford, 2012 The only problem I have with JSON.minify() is that it is really really slow.

So I made my own implementation that does the same thing: gist.github.com/1170297 .

Many parsers and minifiers support JSON comments as well, so just make sure your parser supports them.

JSON is used a lot for application data and configuration settings, so comments are necessary now.

Leave a Reply