cannot flatten arrays of numbers
Closed this issue · 7 comments
noblige commented
print flatten_json.unflatten(flatten_json.flatten({'data' : [2]}))
:
{'data': {'0': 2}}
noblige commented
actually, does not have to be numbers:
print(flatten_json.unflatten(flatten_json.flatten({'data' : ['a']})))
:
{'data': {'0': 'a'}}
aquilax commented
@noblige, unflatten_list
, handles data with flattened lists
>>> print unflatten_list(flatten({'data' : [2]}))
{'data': [2]}
EmSyndio commented
doesn't seem to work with nested objects:
from flatten_json import flatten, unflatten, unflatten_list
a = {"level1":{"level2":[1,2]}}
b = flatten(a,".")
b
{'level1.level2.0': 1, 'level1.level2.1': 2}
c = unflatten(b, ".")
c
{'level1': {'level2': {'1': 2, '0': 1}}}
d = unflatten_list(b,".")
d
{'level1.level2.0': 1, 'level1.level2.1': 2}
EmSyndio commented
seems like the bug is not present in master, but the bug fix is not released.
amirziai commented
@EmSyndio just released v0.1.6
. Try pip install flatten_json --upgrade
and let me know if the issue is fixed.
EmSyndio commented
Works as expected. thanks a lot for the quick release.
amirziai commented
Awesome! Closing the issue.