amirziai/flatten

cannot flatten arrays of numbers

Closed this issue · 7 comments

print flatten_json.unflatten(flatten_json.flatten({'data' : [2]})) :
{'data': {'0': 2}}

actually, does not have to be numbers:
print(flatten_json.unflatten(flatten_json.flatten({'data' : ['a']}))):
{'data': {'0': 'a'}}

@noblige, unflatten_list, handles data with flattened lists

>>> print unflatten_list(flatten({'data' : [2]}))
{'data': [2]}

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}

seems like the bug is not present in master, but the bug fix is not released.

@EmSyndio just released v0.1.6. Try pip install flatten_json --upgrade and let me know if the issue is fixed.

Works as expected. thanks a lot for the quick release.

Awesome! Closing the issue.