I am facing an issue with handling two arrays of JSON objects in JavaScript. I am trying to create a new array by mapping on the "Word_No" property of both arrays. Here is an example of how the arrays look like:
wordInfo (total length: 4000):
[
{
"Word_No": "0",
"Alarm_Bit": "0",
"Alarm_No": "1",
"Alarm_Description": "Alarm text 1"
},
{
"Word_No": "0",
"Alarm_Bit": "1",
"Alarm_No": "2",
"Alarm_Description": "Alarm text 2"
},
{
"Word_No": "0",
"Alarm_Bit": "2",
"Alarm_No": "3",
"Alarm_Description": "Alarm text 3"
}
]
and wordTags (total length: 250):
[
{
"Word_No": "0",
"OPC_Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm0_15"
},
{
"Word_No": "1",
"OPC_Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm16_31"
},
{
"Word_No": "2",
"OPC_Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm32_47"
}
]
I am trying to create a new array named Alarmlist (total length: 4000) with the following structure:
[
{
"OPC Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm0_15",
"Alarm_Bit": "0",
"Alarm_No": "1",
"Alarm_Description": "Alarm text 1"
},
{
"OPC Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm0_15",
"Alarm_Bit": "1",
"Alarm_No": "2",
"Alarm_Description": "Alarm text 2"
},
{
"OPC Tag": "HH.Application.TmpHmi_Var.TmpHmiC7.Alarm0_15",
"Alarm_Bit": "2",
"Alarm_No": "3",
"Alarm_Description": "Alarm text 3"
}
]
My current code using nested loops and mapping on the "Word_No" property is crashing due to the large size of the arrays. When I limit the iteration to a small number, the function works fine. I need a more efficient way to handle this problem. Any suggestions are appreciated.