I pull some data out of MySQL, split this and then format the results to create the JSON I need from each row and am trying to get this to merge correctly but think I am missing something here. The example flow below results in a very similar experience, where the data in is an array which is split. The split data then needs to be merged and not just added to back in if that makes sense:
The names "Main 1" and "Main 2" are not predictable, so I cant pre create anything here.
I am pretty sure I am missing something with the JOIN node that is obvious but after 2 hours I thought I would ask.
Thanks in advance
Data in
[
{
"Main 1": {
"Value 1": ["a","b","c"]
}
},
{
"Main 1": {
"Value 2": ["d","e","f"]
}
},
{
"Main 2": {
"Value 3": ["g","h","i"]
}
},
{
"Main 2": {
"Value 4": ["j","k","l"]
}
}
]
Desired Data Out
[
{
"Main 1": {
"Value 1": ["a","b","c"],
"Value 2": ["d","e","f"]
}
},
{
"Main 2": {
"Value 3": ["g", "h", "i"],
"Value 4": ["j", "k", "l"] }
}
]
Very basic example flow showing the issue:
[
{
"id": "1c4ee0dd73fb2d38",
"type": "inject",
"z": "60f9277b58cf0755",
"name": "Dummy Data",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[{\"Main 1\":{\"Value 1\":[\"a\",\"b\",\"c\"]}},{\"Main 1\":{\"Value 2\":[\"d\",\"e\",\"f\"]}},{\"Main 2\":{\"Value 1\":[\"a\",\"b\",\"c\"]}},{\"Main 2\":{\"Value 2\":[\"d\",\"e\",\"f\"]}}]",
"payloadType": "json",
"x": 140,
"y": 1100,
"wires": [
[
"8e6587393cbfff25"
]
]
},
{
"id": "8e6587393cbfff25",
"type": "split",
"z": "60f9277b58cf0755",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 290,
"y": 1100,
"wires": [
[
"12ef3b2fda25129a"
]
]
},
{
"id": "ce9f79b852656bad",
"type": "debug",
"z": "60f9277b58cf0755",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 1100,
"wires": []
},
{
"id": "12ef3b2fda25129a",
"type": "join",
"z": "60f9277b58cf0755",
"name": "",
"mode": "auto",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 530,
"y": 1100,
"wires": [
[
"ce9f79b852656bad"
]
]
}
]