Hello. I'm trying to declare an array of objects into my msg.payload using a JavaScript node.
I declare my array as such:
msg.payload = {
DeviceID : '0',
Sensors : []
}
And the Sensors array is suposed to contain objects that look like this:
{
SensorID : 'NULL',
Value : 0
}
However, I'm having trouble inserting a new instance of an object into Sensors. For example: If I try to insert a value after the array declaration, ex: msg.payload.Sensors[index].Value = myValue, I get an error telling me that the array Sensors is undeclared, and that I can't set it's value.
How would i go about declaring the Sensors array properly in order to insert new values at a given index?