We do, it’s called TOML. The future is here it’s just not equally distributed.
https://github.com/toml-lang/toml/issues/516
The official way to do list of tables is (look at how much duplication there is)
[[main_app.general_settings.logging.handlers]]
name = "default"
output = "stdout"
level = "info"
[[main_app.general_settings.logging.handlers]]
name = "stderr"
output = "stderr"
level = "error"
[[main_app.general_settings.logging.handlers]]
name = "access"
output = "/var/log/access.log"
level = "info"
vs handlers = [
{
name = "default",
output = "stdout",
level = "info",
}, {
name = "stderr",
output = "stderr",
level = "error",
}, {
name = "access",
output = "/var/log/access.log",
level = "info",
},
]
I would still reach for TOML first if I only needed simple key-value configuration (never YAML), but for anything requiring list-of-tables I would seriously consider JSON with trailing commas instead.(someone may point out to me a CI platform that relies on TOML—which I welcome)
If you need to program complex logic to build a crate, you don’t write TOML. You write a build.rs file in actual Rust.
When configuration gets so complicated that the configuration starts to resemble structured data I tend to prefer to switch to a real scripting language and generate JSON instead.
JSON5?