JSON5 is a superset of JSON that supports comments.
Comment on What is the best file format for configuration file?
simonced@lemmy.one 1 year ago
A lot of good answers but I would add one note:
- use a format that supports comments, and JSON is not one of those…
kersplort@programming.dev 1 year ago
ChairmanMeow@programming.dev 1 year ago
I believe the JSON deserializer .NET ships with has options to allow C#-style comments in JSON files.
vrighter@discuss.tchncs.de 1 year ago
json with comments can be parsed by a yaml parser. It’s how I write yaml, in fact (yaml is a superset of json. any valid json is valid yaml, but it also supports comments)
AeroLemming@lemm.ee 1 year ago
Of course it does!
noli@programming.dev 1 year ago
You disgust me
sfera@beehaw.org 1 year ago
How do you comment multiple properties separately?
AeroLemming@lemm.ee 1 year ago
Please don’t actually do this. Comment stuff in the code and documentation, not the JSON.
sfera@beehaw.org 1 year ago
Don’t worry, I wouldn’t do things like this in JSON. Nevertheless, it can be very useful to have comments along with configuration values, for example to explain the actual values (not their purpose) and why they were chosen. That’s information you can’t add to the code which processes the values.
simonced@lemmy.one 1 year ago
This is actually pretty genius, why haven’t ever thought of that?
AeroLemming@lemm.ee 1 year ago
It’s so easy to use, and you can read the comments from in your program too!
^(in case you weren’t just playing along, please never do comments this way)
simonced@lemmy.one 1 year ago
I liked the idea to be honest. I can just call the entry “description” instead and all is good ^^