htoml
htoml copied to clipboard
Bug with nested tables and arrays
[[fruit.blah]]
name = "apple"
[fruit.blah.physical]
color = "red"
shape = "round"
[[fruit.blah]]
name = "banana"
[fruit.blah.physical]
color = "yellow"
shape = "bent"
From my reading of the toml spec, that should work, and give rise to the following JSON:
{
"fruit":{
"blah":[
{
"name":"apple",
"physical":{
"color":"red",
"shape":"round"
}
},
{
"name":"banana",
"physical":{
"color":"yellow",
"shape":"bent"
}
}
]
}
}
And tomlv
accepts it:
$ tomlv -types fruit.toml ~
fruit.blah ArrayHash
fruit.blah.name String
fruit.blah.physical Hash
fruit.blah.physical.color String
fruit.blah.physical.shape String
fruit.blah ArrayHash
fruit.blah.name String
fruit.blah.physical Hash
fruit.blah.physical.color String
fruit.blah.physical.shape String
However attempting to parse with htoml gives Cannot redefine table ('fruit, blah, physical'
.
This is a very interesting issue. Thanks for reporting it.
I've made a test case for it: https://github.com/cies/htoml/tree/fix/issue-16
@HuwCampbell This issue will need --as I can see it-- quite serious overhaul of the "implicitness tracking logic"; as we need to keep track of it "per array item". Any thoughts on this?
I don't think it should be that complicated, could be such that sub tables of the table arrays are filtered out of the parser state each time a new table array item is declared.