Split a msg.payload into sevral msg.payload

let say your input is :

msg.payload = arthur,aurore,misha

the output will be :

msg1.payload = arthur

msg2.payload = aurore

msg3.payload = misha
[{"id":"90d170d9.67f698","type":"function","z":"7c60e1b7.08dfc8","name":"3 CH Splitter","func":"\n    msg1 = {};\n    msg2 = {};\n    msg3 = {};\n\nvar array = msg.payload.split(','),\n    a = array[0], b = array[1], c = array[2];\n    \n    \n    msg1.payload = a;\n    \n    \n    msg2.payload = b;\n    \n   \n    msg3.payload = c;\n    \n    \n    return [msg1,msg2,msg3];\n","outputs":"3","noerr":0,"x":686,"y":523,"wires":[["3aa8c2fc.c7a1be"],["4ad5996b.afabd"],["5977b03f.2464a8"]]},{"id":"3649aa50.2e2f56","type":"inject","z":"7c60e1b7.08dfc8","name":"","topic":"","payload":"arthur,aurore,misha","payloadType":"str","repeat":"","crontab":"","once":false,"x":279.5,"y":535,"wires":[["90d170d9.67f698","a5ef1d01.828d88"]]},{"id":"3aa8c2fc.c7a1be","type":"debug","z":"7c60e1b7.08dfc8","name":"A","active":true,"console":"false","complete":"payload","x":982.5,"y":460,"wires":[]},{"id":"4ad5996b.afabd","type":"debug","z":"7c60e1b7.08dfc8","name":"B","active":true,"console":"false","complete":"payload","x":985,"y":520,"wires":[]},{"id":"a5ef1d01.828d88","type":"debug","z":"7c60e1b7.08dfc8","name":"source","active":true,"console":"false","complete":"payload","x":518,"y":391,"wires":[]},{"id":"5977b03f.2464a8","type":"debug","z":"7c60e1b7.08dfc8","name":"C","active":true,"console":"false","complete":"payload","x":984,"y":575,"wires":[]}]
arthur1990

Flow Info

created 5 months ago

Node Types

Core
  • debug (x4)
  • function (x1)
  • inject (x1)

Tags

  • split
  • msg
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option