Additionally, the value is a "schema" as opposed to a boolean, meaning you can apply a subschema to any additional fields. Useful if you for instance want to make sure any additional fields start with a specific prefix.
Booleans are valid schemas. It's subschemas all the way down! I wrote an article around this topic: https://json-schema.org/blog/posts/applicability-json-schema...
Regarding the ability to add comments to JSON, it can be done in a cumbersome manner, such as adding a field to an object called "comment", but it is a hack since this wont work for arrays anyway.
JSON is not a data structure. JSON is a data language. A computer program is a data structure and doesn't need comments, a programming language is a format for a human to read, write, and interact with automated tooling, whoss content is a program, but for the human uses, comments are important.
Similarly for data languages.
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-yamlI 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 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[1]: https://json-schema.org/understanding-json-schema/reference/...