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

List type json throwing error while unflattening #5

Closed
mandaltapesh opened this issue Dec 28, 2021 · 1 comment
Closed

List type json throwing error while unflattening #5

mandaltapesh opened this issue Dec 28, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mandaltapesh
Copy link

Hi,

Seeing this error for the json [{'name': 'john'}]

import json_flatten
json_flatten.flatten([{'name': 'john'}])
{'[0].name': 'john'}
res = json_flatten.flatten([{'name': 'john'}])
json_flatten.unflatten(res)
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/json_flatten.py", line 127, in unflatten
if list(obj.keys()) == [""]:
AttributeError: 'list' object has no attribute 'keys'

@simonw simonw added the bug Something isn't working label Oct 29, 2022
@simonw
Copy link
Owner

simonw commented Oct 29, 2022

This library wasn't designed to handle lists as the lowest level element.

Having thought about it bit... I think I'm OK with that restriction, but it needs to return a better error message and be mentioned in the documentation.

@simonw simonw closed this as completed in f32d14b Oct 29, 2022
simonw added a commit that referenced this issue Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants