I have a nested dictionary which I want to flatten while overwriting values of duplicate keys. Example input looks like this:
{
'abc': 1,
'foo': 2
'cba': {'abc': 3, 'baz': {
'foo': 4
}}
}
The goal is to overwrite values of keys in the top level dict with a value of the same key in a lower level dict, where the key in the lowest level dict is ruling.
and the output needs to be this:
{
'abc': 3,
'foo': 4,
'cba': {'abc': 3, 'baz': {
'foo': 4
}}
}
I was trying to find a solution on SO but couldn't find one... Hopefully someone can help me out :)