Hacker News new | past | comments | ask | show | jobs | submit login

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.




But then you need new syntax to indicate subheadings, which is also (probably less) error prone because you might omit it.


I 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}}}


How 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.


> 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... ) 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]`)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: