amirziai/flatten

Issue with unflatten

Opened this issue · 0 comments

When there is a flattened field with a "duplicated" inner part there's an error:
AttributeError: ‘str’ object has no attribute ‘setdefault’
The problematic json:

{
     "field": "",
     "field.inner.part": "123"
}

While this would work:

{
     "field.inner.part": "123"
}

And this would also work:

{
     "field": "",
     "field.inner": "", 
     "field.inner.part": "123"
} 

The desired output for all cases above should be:

{“field”: {“inner”: {“part”: “123”}}}

The function used is:

unflatten_list(example, separator=".")

I don't have a way of removing the "duplicated" ones as this is the way some users input their flattened json.