toml icon indicating copy to clipboard operation
toml copied to clipboard

Object in nested array has no values

Open jacopofar opened this issue 5 years ago • 0 comments

Hello and thanks for the library!

I'm trying to dump an object containing nested arrays of dictionaries, and the output TOML does not contain the values:

import toml

extractors = [
    dict(
        name="Is something",
        patterns=[
            [{"LOWER": "è"}, {"TEXT": {"REGEX": "un"}}, {"POS": "NOUN"}],
        ],
        more_patterns=[
            {"LOWER": "è"}, {"TEXT": {"REGEX": "un"}}, {"POS": "NOUN"},
        ],
        template={'category': 2}),
]
obj = dict(extractors=extractors)

print(toml.dumps(obj))

the output is:


[[extractors]]
name = "Is something"
patterns = [ [ [ "LOWER",], [ "TEXT",], [ "POS",],],]
[[extractors.more_patterns]]
LOWER = "è"

[[extractors.more_patterns]]

[extractors.more_patterns.TEXT]
REGEX = "un"
[[extractors.more_patterns]]
POS = "NOUN"


[extractors.template]
category = 2

the patterns list was transformed into an array of keys but the values are lost.

Is this kind of structure supported? If not I can try and make a PR to raise an error in this scenario.

I'm using toml 0.10.0 and Python 3.7

jacopofar avatar Jan 12 '20 11:01 jacopofar