I'm sure I'm making some obvious mistake, but wanted to check here before I start writing code in a function block.
I have a string with \n characters with in it.
I have that set as the payload, and figured I could have a split node split the payload on every \n, so I could get a payload array made each time \n was pressed.
I feel like I'm missing something obvious since that's what the node defaults to.
but even when I pass in the string: test\ntesting\ntested
that remains one string in the payload, rather than 3 messages.
running on Windows 10 if that makes a difference.
What do I need to do to Split a long string based on \n and format each split into an array?
[
{
"id": "39125df2bacaf839",
"type": "debug",
"z": "60c7ee1b0aa52cb1",
"name": "debug 11",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1760,
"y": 700,
"wires": []
},
{
"id": "f2a2b5cbc288472a",
"type": "split",
"z": "60c7ee1b0aa52cb1",
"name": "",
"splt": "\"\\n\"",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 1610,
"y": 700,
"wires": [
[
"39125df2bacaf839"
]
]
},
{
"id": "3df7822c7506fec0",
"type": "inject",
"z": "60c7ee1b0aa52cb1",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "test\\ntesting\\ntested",
"payloadType": "str",
"x": 1490,
"y": 660,
"wires": [
[
"f2a2b5cbc288472a"
]
]
}
]
EDIT: I know how to do this with a function block using Javascript .split("\n"), I was just curious why the split node doesn't seem to be working as intended. I'm assuming it has something to do with the need for multiple \ Characters in Javascript.