Can we get/update property values using JSON5

26 views
Skip to first unread message

Samuel Paul

unread,
Mar 20, 2014, 7:08:08 AM3/20/14
to js...@googlegroups.com
Hi All,
I have this requirement where I need to read/write jshintrc, jsbeautifyrc files which are json files with comments.
I would like to know if this is possible to do using JSON5?

Thanks
Sam

Aseem Kishore

unread,
Mar 20, 2014, 10:28:29 AM3/20/14
to Samuel Paul, js...@googlegroups.com
Hi Sam,

Do you mean that you'd like to use things like single-quoted strings, unquoted keys, etc. in addition to comments?

If so, your best bet would be to file a feature request with those tools. If they already support comments, it should be trivial for them to support JSON5, and configuration is one of the best use cases for JSON5.

I did a quick search and came across this recent conversation where someone else has also asked for this:



Aside from that, you could check in a JSON5 file alongside the generated regular JSON file (no comments), and use the json5 executable to compile the JSON5 file to the JSON file whenever it changes. This is in fact what we do for the JSON5 package.json as well:


To do this, all you need to do is npm install json5, add it to your package.json, then run something like `node_modules/.bin/json5 -c .jshintrc.json5 && mv .jshintrc.json .jshintrc` as part of your lint task or similar.

Hope that helps!

Aseem




--
You received this message because you are subscribed to the Google Groups "JSON5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json5+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages