3 ms·
> It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging If you want to have comments, consider using YA
by AdieuToLogic 4y ago
> It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging
If you want to have comments, consider using YAML for definitions where possible as it is a superset of JSON[0]:
YAML is also a superset of JSON, so JSON files are valid in YAML.
0 - https://www.redhat.com/en/topics/automation/what-is-yaml https://www.redhat.com/en/topics/automation/what-is-yaml
- AdieuToLogic 4y agoJust for fun, I wondered if YAML '#' comments could exist within a multi-line formatted JSON file. I cannot say the below holds for all YAML libraries, but can say the below works. Assume there is a file named "foo.yaml" which has the following content: { # this is a comment "hello" : "world", array : [ # first number 1, # second number 2 ] } Running: ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' < foo.yaml Yields the below without error: { "hello": "world", "array": [ 1, 2 ] } HTH
- verdverm 4y agoyou can reduce further this by running: cue export foo.yaml --out json If you have an existing JSON file, add // comments wherever and run: cue export cue: - --out json < file.json The `cue: -` tells cue how to interpret stdin and has many options