3 ms·
My main issue with TOML is precisely described in the homepage example: [servers] [servers.alpha] is error prone. An sub heading shouldn't need to know about
by pachico 3y ago
My main issue with TOML is precisely described in the homepage example:
[servers]
[servers.alpha]
is error prone. An sub heading shouldn't need to know about its parent, much less to have to copy it entirely.
- pphysch 3y agoBut then you need new syntax to indicate subheadings, which is also (probably less) error prone because you might omit it.
- petre 3y agoHow do you convert it into a nested object then? You could use deeply nested objects like JSON or YAML does, but then it defeats the purpose of an easy to read configuration format. This is also a feature of Java property files.
- mdaniel 3y ago> This is also a feature of Java property files. To the very best of my knowledge, Properties are merely Map<String,String> (see: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Properties.html#getProperty%28java.lang.String%29 https://docs.oracle.com/en/java/javase/11/docs/api/java.base... ) and any subsequent interpretation happens in the application (e.g. Spring treating `foo[1]=bar` as a list-ish assignment but the actual key returned from `getProperty` is the string literal as written `foo[1]`)
- ryan-duve 3y agoI think it is not needed? Or did you mean something other than this? Python 3.11.3 (main, May 4 2023, 05:53:32) [GCC 10.2.1 20210110] Type 'copyright', 'credits' or 'license' for more information IPython 8.13.2 -- An enhanced Interactive Python. Type '?' for help. In [1]: !cat /tmp/x.toml [servers.alpha] x = 10 In [2]: import tomllib ...: ...: with open("/tmp/x.toml", "rb") as f: ...: t = tomllib.load(f) ...: ...: t Out[2]: {'servers': {'alpha': {'x': 10}}}