I have to different nested dict and I want to replace some keys in dict A with corresponding values in dict B Here is dict A
{
"Animals": {
"catgry": {
"1": "Dogs",
"2": "Cats",
"3": "Birds",
}
},
"dogBreeds": {
"catgry": {
"1": "Belgian Malinois",
"2": "Australian Bulledog",
"3": "Cane Corso",
"4": "Chow chow",
"5": "Dalmatian",
"6": "Dobermann",
"7": "Labrador",
"8": "Rottweiler"
}
}
}
and the dict B is
{
"name": "MyGarden",
"children": [
{
"name": "Animals",
"Animals":"1",
"children": [
{
"name": "dogBreeds",
"dogBreeds":"1",
"children": [
{
"name": "myBelgian malinois",
"weight": "30"
}
]
},
{
"name": "dogBreeds",
"dogBreeds":"2",
"children": [
{
"name": "myAustralian Bulledog",
"weight": "35"
}
]
}
]
}
]
}
I tried first to remove the key 'catgry' from dict A and then replace the values with the corresponding key but didn't succeed without deleting the children also
[EDIT] Here is the expected result
{
"name": "MyGarden",
"children": [
{
"Animals":"Dogs",
"children": [
{
"dogBreeds":"Belgian Malinois",
"children": [
{
"name": "myBelgian malinois",
"weight": "30"
}
]
},
{
"dogBreeds":"Australian Bulledog",
"children": [
{
"name": "myAustralian Bulledog",
"weight": "35"
}
]
}
]
}
]
}