When a default template of dictionary is provided and an input source dictionary is present, how can a new dictionary with same nested structure as template be created while keeping the values for keys in input source as it is?
Example:
template = {
keyA: A,
keyB: B,
keyC: {keyC1: C1,
keyC2: C2},
keyD: {keyD1: {keyD1A: D1A,
keyD1B: D1B},
keyD2: D2}
}
source = {
keyA: A-updated,
keyD: {keyD1: {keyD1A: D1A-updated}
keyD2: D2-updated}
}
output = {
keyA: A-updated,
keyB: B,
keyC: {keyC1: C1,
keyC2: C2},
keyD: {keyD1: {keyD1A: D1A-updated,
keyD1B: D1B},
keyD2: D2-updated}
}