Answer the question
In order to leave comments, you need to log in
What is the name of the dictionary decomposition algorithm?
There is a dictionary
{
"a":"1",
"b":{
"c":{"d":"2",
"e":"3",
}
"f":"4",
}
"g":"5"
}
{
"a":"1",
"b.c.d":"2",
"b.c.e":"3",
"b.f":"4",
"g":"5",
}
Answer the question
In order to leave comments, you need to log in
Not called at all. Traverse recursively nested elements, and that's it:
def nested_to_plain(obj):
result = {}
for key, val in obj.items():
if type(val) == dict:
result.update({ key + '.' + k: v for k, v in nested_to_plain(val).items() })
else:
result[key] = val
return result
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question