I have two json objects. Both may have common keys, Some present only in first object, while some present only in second. When I come these two objects the structure of objects should not change. Only a new level of keys will be added such as the specifying for which object that value belongs to. Even the structure of json objects represent a hierarchy whose levels are not fixed.
a = {"parent1" : { "childa1" : { "grandchilda11" : { "data": values},
"grandchilda12" :{"data" : values }
}
"data" : values
}
{ "childa2" : { "grandchilda21" : { "data": values},
"grandchilda22" :{"data" : values }
}
"data" : values
}
}
b = { "parent1" : { "childa1" : { "grandchilda11" : { "data": values},
"grandchilda12" :{"data" : values }
}
"data" : values
}
{ "childa2" : { "grandchilda21" : { "data": values},
"grandchilda22" :{"data" : values }
}
"data" : values
},
"parent2" : { "childb1" : { "grandchildb11" : { "data": values},
"grandchildb12" :{"data" : values }
}
"data" : values
}
{ "childb2" : { "grandchildb21" : { "data": values}
}
"data" : values
}
}
The resultant should combine this type of json string . The data level here contains directly values while in the resultant it should be like which object it belongs acting as key and then values .
"data" : { "a" : values , "b":values}
valuesis supposed to be: the whole data dictionary, or perhaps the already existing'data'key? If the latter, what is the expected behavior? Flattening the values?dict. Plain old Python dicts. Most used type in the language, very well documented. Now could you please edit your question with at least 1. a complete example of inputs and expected outputs for these inputs ("values" is not a complete example) and 2. what you tried that didn't work ?