Open ttamg opened 1 year ago
This is also related to issue #43 but in the case where our nested dictionary has empty lists []
[]
In this case, not only do we have the empty <FlatterDict {}>, but in the flat form it encodes the empty list as an empty dictionary instead.
<FlatterDict {}>
In the original as_dict() form it is correct as you would expect. The issue is in the flattened form.
as_dict()
Here is a simple example
dict_ = {"age": 25, "siblings": []} flat = flatdict.FlatterDict(dict_) print(flat.as_dict()) print([(k, v) for k, v in flat.items()]) print(flat['siblings'])
Outputs
{'age': 25, 'siblings': []} [('age', 25), ('siblings', <FlatterDict id=5520522448 {}>")] {} # wrong should be []
bump
I have a PR out that should fix this https://github.com/gmr/flatdict/pull/57
print(FlatDict({'a': {}, 'b': []}).as_dict()) {'a': {}, 'b': []}
This is also related to issue #43 but in the case where our nested dictionary has empty lists
[]
In this case, not only do we have the empty
<FlatterDict {}>
, but in the flat form it encodes the empty list as an empty dictionary instead.In the original
as_dict()
form it is correct as you would expect. The issue is in the flattened form.Here is a simple example
Outputs