Becker
1
Hi,
can someone please tell me how to create an object from any number of messages from my flow?
msg1 = {};
msg1.payload = {"Spreizung KT": msg.payload};
msg2 = {};
msg2.payload = {"THub": Number(msg.payload)};
msg3 = {};
msg3.payload = {"Leistung nach ZH": msg.payload};
return msg1,msg2,msg3;
this function doesn´t work, it makes 3x objects.
the output of the function should be like the buffer parser output:
Thanks.
E1cid
2
let msg1 = {"payload":{}};
msg1.payload.Spreizung KT= msg.payload;
msg1.payload.THub=Number(msg.payload);
msg1.payload["Leistung nach ZH"]=msg.payload;
return msg1;
Then dont make 3 objects - update the payload of 1 object instead.
msg.payloadOrig = msg.payload;
msg.payload = {
"Spreizung_KT": msg.payload,
"THub": Number(msg.payload),
"Leistung_nach_ZH": msg.payload
}
return msg;
PS...
for debugging and other reasons I wont go into right now, it is usually best to re-use the original msg
object instead of creating new objects.
This wont work - you cant have spaces in a property name unless you use []
square bracket notation.
E1cid
5
Cheers missed the spaces, edited code.
Becker
6
I´m a fool, just finished taking the join node
sorry
javascript is tough
Colin
7
Most things are tough initially. Don't worry about it.
Becker
8
i always like to learn new things.
Javascript can do so much and I probably don't even know 1% of it.
system
Closed
9
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.