msg.topic = "SELECT title, id FROM services";
return msg;[ { "title": "Thema A", "id": 1 }, { "title": "Thema B", "id": 2 }, { "title": "Thema C", "id": 3 } ]
[ { "Thema A", 1 }, { "Thema B", 2 }, { "Thema C", 3 } ]
var outputArray = [];
for(var i in msg.payload){ var entryData = [msg.payload[i]['title']]; for(var attr in msg.payload[i]) { if(attr!='title') { entryData.push(msg.payload[i][attr])} } outputArray.push(entryData); }
var returnMsg={"options":outputArray};return returnMsg;[ [ "Thema A", 1 ], [ "Thema B", 2 ], [ "Thema C", 3 ] ]
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/10c41f74-6dbb-4ffb-b1e5-a733780245d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
As per the release blog post, the change node has jsonata support - it's in the dropdown list of types.
Nick
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/d0fc5fa4-d459-49e4-b40b-f56d90996b7a%40googlegroups.com.
[ { "id": "f7b73b78.3823b8", "type": "inject", "z": "a896d148.586bc", "name": "Array of objects", "topic": "", "payload": "[ { \"title\": \"Thema A\", \"id\": 1 }, { \"title\": \"Thema B\", \"id\": 2 }, { \"title\": \"Thema C\", \"id\": 3 } ]", "payloadType": "json", "repeat": "", "crontab": "", "once": false, "x": 140, "y": 340, "wires": [ [ "6fa91881.dc6378" ] ] }, { "id": "6fa91881.dc6378", "type": "change", "z": "a896d148.586bc", "name": "build {key: val} array", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "msg.payload.{title: id}", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 380, "y": 340, "wires": [ [ "306cc493.091e5c" ] ] }, { "id": "306cc493.091e5c", "type": "debug", "z": "a896d148.586bc", "name": "", "active": true, "console": "false", "complete": "false", "x": 630, "y": 340, "wires": [] }]