Because it avoids these problems, your "name.alternative.first" example seems perfectly sensible to me. Alternatively, the name might be an array:
[[name]]
first = "Bob"
last = "Smith
[[name]]
first = "Robert"
It's probably best to think of TOML as convenient syntax for creating a JSON-like structure. What kind of JSON would you expect as the result of your config examples?Your explanation is perfect and I understand the justification why it isn't possible now - so thanks for that! The array alternative provided by xinau is also an acceptable replacement - maybe even better to be honest, especially in this particular scenario.
>It's probably best to think of TOML as convenient syntax for creating a JSON-like structure. What kind of JSON would you expect as the result of your config examples?
I came back from lunch and realized what I was trying to do didn't make sense while trying to convert it to JSON. Having name.first be both a value and contain an object doesn't make sense - unless it were to contain an array value but then why have the object and not just have the value? All very silly. So I guess my "only issue with TOML" is that I never sat down and tried to express what I wanted to express in any other way. It made a lot more sense in my head than on paper. :)
One key can't have multiple values with different types. For example in json:
{ "name" :
{ "first" : "Bob",
"last" : "Smith"
}
}
How would you add a "alternative" key to the "first" value type. The only way i can think of is something like this. { "name" :
{ "first" : "Bob",
"first.alternative": "Robert",
"last" : "Smith"
}
}
or as @latk suggested, let "first" be an array, with it's first entry being the non alternatives. { "name" :
{ "first" : ["Bob", "Robert"],
"last" : "Smith"
}
}
I think this is by design. To quote @mojombo "simple configuration file that maps unambiguously to a hash table".But this is only a guess.