Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use TOML variables to nest TOML tables in other TOML tables?

Tags:

json

toml

Can I put a TOML table into a TOML variable and then use that variable in another TOML table? I would like to replicate JSON ouput like this:

group1 = {
    "key1": "value1"
    "key2": "value2"
    "key3": {
        "key1": "value4"
        "key2": "value5"
        "key3": "value6"
    }
}

group2 = {
    "key1": "value1"
    "key2": "value2"
    "key3": {
        "key1": "value4"
        "key2": "value5"
        "key3": "value6"
    }
}

mainGroup = {
    "key1": "value1"
    "key2": "value2"
    "key3": group1
    "key4": {
        "key1": "value3"
        "key2": "value3"
        "key3": group2
    }
    "key5": {
        "key1": group1
        "key2": group2
    }
}
like image 576
Teatree Avatar asked Sep 01 '25 05:09

Teatree


1 Answers

Toml does not support references as Yaml does.

Readability and ease of implementation were some of the reasons for the developers of Toml to leave this out of the standard.

An interesting discussion about this topic can be read here:

https://github.com/toml-lang/toml/issues/77

like image 51
alex-dl Avatar answered Sep 02 '25 20:09

alex-dl