Combine payloads into 1 JSON object

Hi there,

I want to combine the different outputs from OPCUA client into 1 JSON object, to be published to MQTT.

This is how the flow looks like:

And the output from the client looks like this:

So, my plan was to filter out the different messages by the topic, and combine the payload into 1 JSON object. The topic is the same as the opcua-string.

Any ideas for how this can be done? Hopefully within one function node.

Thanks in advance :slight_smile:

That's what the join node is for.
image

1 Like

Wow, that was almost too perfect, thanks :slight_smile:

Any easy way to remove this part of the string/name?
image

Function node before the join...

msg.topic = msg.topic.replace('ns=4;s=|var|HetlelidAuto.Application.0PCUA.','')
return msg

(Likely a typo in what I wrote but you did post a picture instead of text! ,:man_shrugging:

@Steve-Mcl answer is correct short, simple and easy

I would use https://flows.nodered.org/node/node-red-contrib-string for this if there is any chance that,

ns=4;s=|var|HetlelidAuto.Application.0PCUA.

could change in the future.