Here is an example array:
let Given = [
["SRM_SaaS_ES,MXASSETInterface,AddChange,EN"],
["ASSETNUM,AS_SITEID,apple,ball"],
["mesa01,SDASITE,ball,cat"],
["ASSETNUM,AS_SITEID,cat,ager"]
];
I want to organize the data in a specific way:
let needed = [{
'SRM_SaaS_ES': 'ASSETNUM',
'MXASSETInterface': 'AS_SITEID',
'AddChange': 'apple',
'EN': 'ball',
},
{
'SRM_SaaS_ES': 'mesa01',
'MXASSETInterface': 'SDASITE',
'AddChange': 'ball',
'EN': 'cat',
},
{
'SRM_SaaS_ES': 'ASSETNUM',
'MXASSETInterface': 'AS_SITEID',
'AddChange': 'cat',
'EN': 'ager',
}
]
I attempted to extract the keys from the first array and assign them accordingly but faced challenges.
let firstArrayData: string = this.Given[0];
let data = firstArrayData[0].split(',');
console.log(JSON.stringify(data));//["SRM_SaaS_ES","MXASSETInterface","AddChange","EN"]