JSON with comments
Recently I saw a thread on twitter about various techniques for hacking comments into JSON:
While this is clever, it... makes me fill icky.
Why was this done? Presumably because creating your own file format ("JSON with comments"), along with a JSON-with-comments to JSON "compiler" which strips the comments out, was seen as being too difficult.
But is it?
#!/bin/bash # Produces a .json file by stripping the comments from a .jsonc file. infile=$1 outfile=`basename $infile .jsonc`.json cat $infile | sed '/[[:space:]]*\/\//d' > $outfile
Might as well throw in an example Makefile
foo.json: foo.jsonc jsonc-to-json.sh foo.jsonc