I have 2 objects, one original and one updated. The object has many nested objects. i need to get the updated key-value pairs alone
originalObject = {
alphaKey: "alphaValue",
betaKey: {
betaAlphaKey: "betaAlphaValue",
betaBetaKey: 123456,
},
gammaKey: "gammaValue",
deltaKey: {
deltaAlphaKey: "deltaAlphaValue",
deltaBetaKey: {
deltaBetaAlphaKey: "deltaBetaAlphaValue",
deltaBetaBetaKey: "deltaBetaBetaValue",
},
deltaGammaKey: "deltaGammaValue",
},
epsilonKey: "epsilonValue",
zetaKey: {
zetaAlphaKey: "zetaAlphaValue",
zetaBetaKey: 111222,
zetaGammaKey: {
zetaGammaAlphaKey: "zetaGammaAlphaValue",
zetaGammaBetakey: "zetaGammaBetaValue",
zetaGammaGammaKey: 222333444,
},
},
};
and
updatedObject = {
alphaKey: "alphaValue",
betaKey: {
betaAlphaKey: "betaAlphaValue",
betaBetaKey: 000123456,
},
gammaKey: "gammaValue",
deltaKey: {
deltaAlphaKey: "updatedDeltaAlphaValue",
deltaBetaKey: {
deltaBetaAlphaKey: "deltaBetaAlphaValue",
deltaBetaBetaKey: "updatedDeltaBetaBetaValue",
},
deltaGammaKey: "deltaGammaValue",
},
epsilonKey: "epsilonValue",
zetaKey: {
zetaAlphaKey: "updatedZetaAlphaValue",
zetaBetaKey: 000111222,
zetaGammaKey: {
zetaGammaAlphaKey: "zetaGammaAlphaValue",
zetaGammaBetakey: "updatedZetaGammaBetaValue",
zetaGammaGammaKey: 011222333444,
},
},
};
i want to compare these 2 and get output the upadted fields alone
output = {
betaBetaKey: 000123456,
deltaAlphaKey: "updatedDeltaAlphaValue",
deltaBetaBetaKey: "updatedDeltaBetaBetaValue",
zetaAlphaKey: "updatedZetaAlphaValue",
zetaBetaKey: 000111222,
zetaGammaBetakey: "updatedZetaGammaBetaValue",
zetaGammaGammaKey: 011222333444
}
so, can you please help me in this
The code is expected to retrieve the nested objects, compare them with original fields, and save the updated fields in output
Thanks