How may I insert automatically this object information to create new keys.

Value to be automatically insert, value of payload.measurementTypeCode
I tried this below, but return an error: expected ":" and instead saw "."
var data = {
msg.payload.measurements[0].measurementTypeCode.toString() : msg.payload.measurements[0].measurementValue.toString()
}
This is called square brackets notation...
var data = {}
data[msg.payload.measurements[0].measurementTypeCode] = msg.payload.measurements[0].measurementValue;
msg.payload = data;
return msg;
That will obviously only do the first element in the payload array.
1 Like
Thanks, that solved my problem. I am so gratefull
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.