Programming Tips - Alternatives to JSON for config files
Date: 2020mar22
Q. Alternatives to JSON for config files
A. JSON is really unfriendly for human editing.
Its fine for program-to-program communication.
But has some issues when humans might be involved:
- Overly verbose (eg you need to quote variable names - "name":"Dave")
- Only doublequotes, no single quotes (which makes quoting text with double quotes messy)
- No comments
- Trailing commas are strictly forbidden
If you are making a file that will be seen or editing by humans
consider something better.
Relaxed JSON (RJSON)
http://www.relaxedjson.org
TOML
https://en.wikipedia.org/wiki/TOML
JSON5
https://json5.org
JSONNET
https://jsonnet.org
YAML (Not so great because whitespace is significant)
http://yaml.org/
Markdown (But most for documents)
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
javaScript (BAD)
javaScript supports comments and is more lenient than JSON.
But can only be imported with eval() which is dangerous.