I wanna try to create one JSON array in node by combine these two JSON and JSON arrays
`var template = {
"key1": "value1",
"key3": "value3",
"key4": "value3",
"key6": "Dummy Value1"
};
var data = [
{
"value1": "1",
"value2": "2",
"value3": "3"
},
{
"value1": "11",
"value2": "12",
"value3": "13"
},
{
"value1": "21",
"value2": "22",
"value3": "23"
}
];`
I need Resulted JSON be like
var result = [
{
"key1": "1",
"key3": "3",
"key4": "3",
"key6": "Dummy Value1"
},
{
"key1": "11",
"key3": "13",
"key4": "13",
"key6": "Dummy Value1"
},
{
"key1": "21",
"key3": "23",
"key4": "23",
"key6": "Dummy Value1"
}
]
In my case there will be around 40 keys in JSON array and around 25 keys in template JSON, So I'm also looking for Optimized solution for this. Anybody can help me in this?
dataarray ? Why is therekey1 : 1, key3 : 3, key4 :3everywhere ? You just want to replace every data with the template ?