Convert array to a specified string for a telnet connection

Hey,
i please need help with a function node.
From a sql query i get an array with a variable number of objects.
Example:

Now i need to send this data via a telnet connection to my device as follows:

1010000021325-020|1090000021219-025C|.....

Can please anybody help me with the function node to realize this?

Thanks in advance

Tim

Try

msg.payload = msg.payload.map(v => Object.values(v).join("")).join("|");
return msg;
1 Like

Something like this might get you close:

msg.payload = Object.entries(msg.payload);
let result = "";
for (let i = 0; i < msg.payload.length; i++) {
    result += msg.payload[i][1];
};
msg.payload = result;
return msg;

Thank to both of you!
This works well for me.
Thank you for your help!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.