Given all three languages are JSON compatible, you should always provide a JSON schema, and NFD should validate the document against the JSON schema before proceeding.
Using schema validation can eliminate a lot of complexities in parsing, such as "negative port number", "string as port number", "prefix propagation and /localhop/nfd/rib cannot be enabled at the same time".
JSON¶
There's no way to insert comments in standard JSON.
JSON with comments can be an option.
TOML¶
Editing TOML on command line doesn't require compiling tools during deployment:
- Use
tomljson
from go-toml to convert TOML to JSON.
- Use jq to edit JSON.
- Use
jsontoml
from go-toml to convert JSON to TOML.
jq has Ubuntu packages.
go-toml can be pre-compiled once and anyone can wget
them. Go binaries are statically linked and will work on all versions of Linux or macOS.
A drawback of TOML is that, JSON document is not valid TOML document, so that tools that produce JSON must be filtered through jsontoml
.
YAML¶
YAML is a classical configuration format.
Its benefit is that, machine generated configuration files can use JSON, and all YAML parsers will accept them.
However, YAML is too complicated and human can make mistakes.