I have two object one is flatten obj and another is unflatten. I need to override flatten object with flat object if the level is same..
example
const b = {
"customerDetails": {
"freight_forwarder": null,
"account_holder": null,
},
}
const a= {
"customerDetails.freight_forwarder": {
"label": "APL ",
"value": "4c4bb555-154f-4e84-ab07-641d6dd37c4e"
},
"customerDetails.account_holder": {
"label": "AAR",
"value": "4cd309f5-66d5-459f-a06e-9b52298a87b3"
},
}
console.log({
...b,
...a
})
current output
{
"customerDetails": {
"freight_forwarder": null,
"account_holder": null
},
"customerDetails.freight_forwarder": {
"label": "APL ",
"value": "4c4bb555-154f-4e84-ab07-641d6dd37c4e"
},
"customerDetails.account_holder": {
"label": "AAR",
"value": "4cd309f5-66d5-459f-a06e-9b52298a87b3"
}
}
expected output :
{
"customerDetails.freight_forwarder": {
"label": "APL ",
"value": "4c4bb555-154f-4e84-ab07-641d6dd37c4e"
},
"customerDetails.account_holder": {
"label": "AAR",
"value": "4cd309f5-66d5-459f-a06e-9b52298a87b3"
}
}
shall I flatten the first OBJECT ?? or any other way ?