Reputation: 4624
say I have two dictionaries; orig
and inner
how to create json object from them such that inner
is embedded insider orig
:
orig = {
'A': 1,
'B': 2,
'C': 3
}
inner = {
'D': 4,
'E': 5
}
#embed inner insider orig
new = {
'A': 1,
'B': 2,
'C': 3,
'inner':{
'D': 4,
'E': 5
}
}
Upvotes: 0
Views: 144
Reputation: 184
I don't think that's possible. There would be no value to access the inner dictionary from.
You could do:
new = {
'A': 1,
'B': 2,
'C': 3,
'inner': {
'D': 4,
'E': 5
}
}
with: orig['inner'] = inner
but with structure you posted there would be no way to access the inner dict.
Upvotes: 1