I wanted to merge nested javascript object. I was simple when I the length of object was one. But since the lenght has increased I need a dynamic way to merge the address
key and serialize my object
var old = {account: "100000", address: {city: "LONDON", companyName: "Test IQUE", country: "UK", postalCode: "SW1A 2AA",}, meterName: "DM9"}
When lenght was 1 this worked for me
var new = {
'account' : "100000",
'address' : "LONDON, UK"
'companyName' : "Test IQUE",
'postalCode' : "SW1A 2AA",
'meterName' : "DM90"
},
{
'account' : "1000001",
'address' : "LONDON, UK"
'companyName' : "Test IQUE",
'postalCode' : "SW1A 2AA",
'meterName' : "DM90"
};
Baiscally I need to serialize my nested address
object and merge it into one. As the structure of each object will be same I was thinking of using a for each loop which can combine values of address into one.