4 ms·
"JSON isn't the friendliest to write and maintain by hand." And this is a problem why, since it SHOULDN'T BE WRITTEN BY HAND? This suggestion adds additional
by al2o3cr 13y ago
"JSON isn't the friendliest to write and maintain by hand."
And this is a problem why, since it SHOULDN'T BE WRITTEN BY HAND?
This suggestion adds additional complexity to every parser of the "new" format, in exchange for... nothing, apart from a few less syntax errors for sloppy hand-editors. WTF.
- diydsp 13y agoI have a silly question, only having used JSON a precious few times, but if people want comments in JSON, couldn't that be done just by a named field within an object that follows the existing specification, iow an optional property holding a string?
- MichaelGG 13y agoBy doing that, you've now added more data to the object. It'd be like doing <tag comment='bar' /> in XML - the actual data has changed. So you'd end up defining some well-known comment name. But then you can't serialize arbitrary data structures, because they might conflict. So that gets complicated. After everything, the JSON spec could have allowed comments to stay in. Instead, the author went off on some nonsense reasoning about incompatibility.
- captainmuon 13y agoWhy shouldn't it be written by hand? If you have an object or list literal in your JS, it's already "almost-JSON". People write a lot of "almost-JSON". I want to separate data from code and put it into a data file, but then I have to remove final commas, comments, and so on. This is great for static data that would otherwise be in your code. Also it is great as a config file format. Sublime Text uses JSON+comments, for example. Everybody who knows Python, JS, or JSON knows how to use it immediately. I don't know where the problem is, since with the current implementation it is not possible to write JSON5 not by hand! JSON5.stringify just calls the reference JSON serializer. The added complexity is not much, and has already been implemented. You don't need to change every implementation. It's just a drop-in replacement for JSON so you can have comments in your static JSON data files. I think it's extremely convenient. Using JSON as a config file format in Sublime Text for example is only viable since they are heavily commented.