【发布时间】:2016-06-24 12:03:31
【问题描述】:
我有一个 json 对象,它可以嵌套,我还有一个包含键/值对的对象。我想通过匹配两个对象的键来将第二个对象的值替换为第一个对象的值。
let firstObj = {
"enquiry": {
"Lead": {
"SubLead": {
"DealerRef": "test",
"DealerFloor": "test",
"Region": "test",
"Source": {
"Special": "test",
"TestDrive": "test",
"TradeIn": "test",
"Finance": "test"
}
},
"Contact": {
"Info": {
"FirstName": "test",
"Surname": "test",
"Email": "test",
"OfficePhone": "test",
"CellPhone": "test"
}
},
"Seeks": {
"Stock": {
"Used": "test",
"Brand": "test",
"Model": "test",
"StockNr": "test"
}
}
}
}
}
这是我的数组
let secondObj = {
DealerRef: '18M',
DealerFloor: 'UCP',
Region: 'Western Cape',
FirstName: 'abc',
Surname: 'xyz',
Email: 'test@ctm.co.za',
OfficePhone: '2343243',
CellPhone: '2343243',
Used: '1',
Brand: 'QAE',
Model: 'test',
StockNr: 'SEDONA',
Special: '2013 Kia Sedona',
TestDrive: '0',
TradeIn: '0',
Finance: '0'
};
我尝试了很多方法 [http://jsfiddle.net/FM3qu/7/][1] 这样我就可以在 Jsfiddle 中获得解决方案,在我的快速应用程序中,当我尝试处理它时,它会给我一个空对象。
我想要这样的东西
"enquiry": {
"Lead": {
"SubLead": {
"DealerRef": "18M",
"DealerFloor": "UCP",
"Region": "Western Cape"....
谢谢
【问题讨论】:
标签: javascript node.js express ecmascript-6