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

This is not meant to be adopted, as in, replacing JSON everywhere.

It doesn't make sense for REST APIs. It doesn't make sense for communication between programs. In fact, its basically impossible to use this implementation for that, because (the last time I checked) JSON5 just used the JSON reference serializer. If you create JSON programmatically, it will always be valid vanilla JSON!

The use case is hand-written JSON. Either for configuration files (like Sublime Text). Or if you have hand-written data that you would otherwise put in a object in a .js file. You might want to separate your data from your code, but you can't just dump the javascript object literal into a json file, because it's not valid JSON. And maybe you want to leave comments in there, or trailing commas in lists.

If you send JSON over the wire, its trivial to sanitize it:

    JSON5.stringify(JSON5.parse(sloppy_json))
This will also remove comments of course, if you are concerned about them eating bandwidth.


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

Search: