Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with unflatten #81

Open
mritay opened this issue Mar 16, 2022 · 0 comments
Open

Issue with unflatten #81

mritay opened this issue Mar 16, 2022 · 0 comments

Comments

@mritay
Copy link

mritay commented Mar 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant