4 ms·
If you are going to put comments in your JSON, please use the /* */ style. It is often useful to express a JSON object as a single line of text. Comments that
by billpg 2y ago
If you are going to put comments in your JSON, please use the /* */ style.
It is often useful to express a JSON object as a single line of text. Comments that start from a symbol ("#" or "//") and continue to the end of the line can't be joined into a single line of text without throwing away the comments. /* */ is distinct by having an explicit end-of-comment symbol that allows meaningful text afterwards.
- bloak 2y agoAnd then you don't need to invent a new version of JSON: you just preprocess the file/string with the C preprocessor? (I don't like the C preprocessor but in some situations it's the easiest solution.)
- billpg 2y agoI would caution against using the C pre-processor, unless you're very careful indeed. {"data": #include "/home/myservice/secrets.json" }
- Pikamander2 2y agoSingle-line and multi-line comments have different use cases. Any good language should support both # and /**/ // is unnecessary, though. It adds nothing besides an extra character to type.