JSON does not natively support comments, which is OK, but sometimes a comment could really help.
If the application loading the JSON does not care about additional keys
we can simply add a key with our favorite comment indicator like //
or #
.
{
"//": "This setting enables not just A, but somehow also B",
"enable_feature_a": true
}
Tip
While this works consider using a different file format better suited for configuration.
If you are using a IaC tool like Ansible to generate the configuration file you could also store it as YAML, with comments, and only process it to JSON at the last second.