msg.parts = {
id: "abc123", // 分割グループの識別子
index: 0, // このメッセージの順番(0から)
count: 3, // 総分割数
type: "array", // 元のデータ型
key: "Apple" // オブジェクト分割時のキー名
}
📋 サンプルフロー(クリックで展開)
参照元:NodeREDエディター内サンプルフロー
[
{
"id": "0276807ceed12df2",
"type": "tab",
"label": "split",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f94ffc33.76f83",
"type": "comment",
"z": "0276807ceed12df2",
"name": "Example: Split Message Payload",
"info": "Split node can be used to split message payload into multiple messages.",
"x": 330,
"y": 120,
"wires": []
},
{
"id": "657bb57c.a3f98c",
"type": "split",
"z": "0276807ceed12df2",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"property": "payload",
"x": 650,
"y": 220,
"wires": [
[
"14228ff.ae24f7"
]
]
},
{
"id": "2afece55.b87de2",
"type": "inject",
"z": "0276807ceed12df2",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 360,
"y": 220,
"wires": [
[
"cfca3863.d961d8"
]
]
},
{
"id": "cfca3863.d961d8",
"type": "template",
"z": "0276807ceed12df2",
"name": "data",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "plain",
"template": "Apple\nOrange\nBanana",
"output": "str",
"x": 510,
"y": 220,
"wires": [
[
"657bb57c.a3f98c"
]
]
},
{
"id": "14228ff.ae24f7",
"type": "debug",
"z": "0276807ceed12df2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 800,
"y": 220,
"wires": []
},
{
"id": "9a3c9494.b5d178",
"type": "comment",
"z": "0276807ceed12df2",
"name": "Split input text by specified string",
"info": "",
"x": 370,
"y": 180,
"wires": []
},
{
"id": "38c873c.5ae718c",
"type": "comment",
"z": "0276807ceed12df2",
"name": "→ split by newline (\\n)",
"info": "",
"x": 700,
"y": 260,
"wires": []
},
{
"id": "bdfa12b9.3fbbc",
"type": "split",
"z": "0276807ceed12df2",
"name": "",
"splt": "4",
"spltType": "len",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"property": "payload",
"x": 650,
"y": 340,
"wires": [
[
"debf23bb.c0245"
]
]
},
{
"id": "7c0948db.e35d38",
"type": "inject",
"z": "0276807ceed12df2",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 360,
"y": 340,
"wires": [
[
"7f791b7d.94cad4"
]
]
},
{
"id": "7f791b7d.94cad4",
"type": "template",
"z": "0276807ceed12df2",
"name": "data",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "plain",
"template": "Apple\nOrange\nBanana",
"output": "str",
"x": 510,
"y": 340,
"wires": [
[
"bdfa12b9.3fbbc"
]
]
},
{
"id": "debf23bb.c0245",
"type": "debug",
"z": "0276807ceed12df2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 800,
"y": 340,
"wires": []
},
{
"id": "f05e98a3.4182c8",
"type": "comment",
"z": "0276807ceed12df2",
"name": "Split input text by specified number of characters",
"info": "",
"x": 420,
"y": 300,
"wires": []
},
{
"id": "86b52b51.2258d8",
"type": "comment",
"z": "0276807ceed12df2",
"name": "→ split by four characters",
"info": "",
"x": 710,
"y": 380,
"wires": []
},
{
"id": "71d7c0e0.c0316",
"type": "split",
"z": "0276807ceed12df2",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"property": "payload",
"x": 650,
"y": 480,
"wires": [
[
"bee5b6a2.a955a8"
]
]
},
{
"id": "1cdc2df9.bebdd2",
"type": "inject",
"z": "0276807ceed12df2",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 360,
"y": 480,
"wires": [
[
"f30df13c.19475"
]
]
},
{
"id": "f30df13c.19475",
"type": "template",
"z": "0276807ceed12df2",
"name": "data",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "[ \n \"Apple\",\n \"Orange\",\n \"Banana\"\n]",
"output": "json",
"x": 510,
"y": 480,
"wires": [
[
"71d7c0e0.c0316"
]
]
},
{
"id": "bee5b6a2.a955a8",
"type": "debug",
"z": "0276807ceed12df2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 800,
"y": 480,
"wires": []
},
{
"id": "b2c731fe.abda4",
"type": "comment",
"z": "0276807ceed12df2",
"name": "Split input array",
"info": "",
"x": 320,
"y": 440,
"wires": []
},
{
"id": "1f557227.d0910e",
"type": "comment",
"z": "0276807ceed12df2",
"name": "→ split array",
"info": "",
"x": 670,
"y": 520,
"wires": []
},
{
"id": "c0d43ff4.291d8",
"type": "split",
"z": "0276807ceed12df2",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "topic",
"property": "payload",
"x": 650,
"y": 600,
"wires": [
[
"fc9fe458.50fd18"
]
]
},
{
"id": "6d52ce8a.0c715",
"type": "inject",
"z": "0276807ceed12df2",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 360,
"y": 600,
"wires": [
[
"bdeb8c21.1c6b7"
]
]
},
{
"id": "bdeb8c21.1c6b7",
"type": "template",
"z": "0276807ceed12df2",
"name": "data",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{ \n \"Apple\": 80,\n \"Orange\": 100,\n \"Banana\": 50\n}",
"output": "json",
"x": 510,
"y": 600,
"wires": [
[
"c0d43ff4.291d8"
]
]
},
{
"id": "fc9fe458.50fd18",
"type": "debug",
"z": "0276807ceed12df2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 780,
"y": 600,
"wires": []
},
{
"id": "48956e14.79b86",
"type": "comment",
"z": "0276807ceed12df2",
"name": "Split object to key/value pairs",
"info": "",
"x": 360,
"y": 560,
"wires": []
},
{
"id": "d528c2c2.6efc7",
"type": "comment",
"z": "0276807ceed12df2",
"name": "→ split object",
"info": "",
"x": 670,
"y": 640,
"wires": []
}
]
分割: 文字列 "\n"
入力: "Apple\nOrange\nBanana"
出力: 3つのメッセージ
1. msg.payload = "Apple"
2. msg.payload = "Orange"
3. msg.payload = "Banana"
分割: 固定長 4文字
入力: "AAAABBBBCCCC"
出力: 3つのメッセージ
1. msg.payload = "AAAA"
2. msg.payload = "BBBB"
3. msg.payload = "CCCC"
分割: 配列 (自動認識)
入力: ["Apple", "Orange", "Banana"]
出力: 3つのメッセージ
1. msg.payload = "Apple", msg.parts.index = 0
2. msg.payload = "Orange", msg.parts.index = 1
3. msg.payload = "Banana", msg.parts.index = 2
分割: オブジェクト
キー追加先: msg.topic
入力: {"Apple": 80, "Orange": 100, "Banana": 50}
出力: 3つのメッセージ
1. msg.payload = 80, msg.topic = "Apple"
2. msg.payload = 100, msg.topic = "Orange"
3. msg.payload = 50, msg.topic = "Banana"