Trying to add a new variable in a array and make it null

Hi I am trying to add new variable to an array and make it as null, how can I achieve that.

Below is the example, in doc1 I don’t have “Cde”Array, compared to doc2. In such scenarios in doc1 I need to create that variable and assign it as null.
Doc1:

“xyz”: [
{
“Abc”:1
}
]

Doc2

“Xyz”:[
{
“Cde”: [
{
“zen”:5
}
]
“Abc”:1
},
]

The general procedure would be:

  • Iterate pairwise over both list
  • For each iteration:
    • Iterate the keys of the “source”
    • If key doesn’t exist in “dest”, create.

The last bullet point above is implementable like this:

if key not in dest:
    dest[key] = None

Or one liner:

dest.setdefault(key, None)

Also, next time please wrap your code between two lines of “triple backticks” ```