I have an json object(firstObj) It can be nested and I have an second object containing key/value pair. I want to replace the second object's value by first one by matching value and do it's operation.
let firstObj = {
amount_money: {
amount: {
mapped_field: 'payment_amt',
operation: '/10'
},
currency: {
mapped_field: 'payment_cur',
operation: null
}
},
source_id: {
mapped_field: 'request_id',
operation: null
},
ship: [
{ mapped_field: 'ship_country[0]', operation: null },
{ mapped_field: 'ship_country[1]', operation: null }
]
};
my second object
let secondObj = {
payment_amt: 100,
payment_cur: 'USD',
request_id: '123ASD',
ship_country: [
{ code: 'USA', Title: 'America' },
{ code: 'UK', Title: 'England' }
]
};
I want something like this
{
amount_money: {
amount: 10
currency: 'USD'
},
source_id: '123ASD',
ship: [ {America: 'USA'}, {England: 'UK'}]
}
Really appreciate your kind help, Thank you!