I'm a NodeRED newbie trying to figure out how to split an array, select some values and join the selected values back into an array.
My sample works fine if I select all values.
I discard values I don't get a result.
Extra questions :
- Can I split the values directly without the values2payload change
[{"id":"f20aa3b6.3ed58","type":"inject","z":"def5c4c1.d0947","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"values\":[{\"name\":\"1 keep\",\"keep\":\"true\"},{\"name\":\"2 keep\",\"keep\":\"true\"},{\"name\":\"3 drop\",\"keep\":\"false\"},{\"name\":\"4 keep\",\"keep\":\"true\"},{\"name\":\"5 drop\",\"keep\":\"false\"}]}","payloadType":"json","x":90,"y":80,"wires":[["b18d8293.ceaa1"]]},{"id":"27f5d0bb.200d3","type":"split","z":"def5c4c1.d0947","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":80,"wires":[["a23e9796.102ba8"]]},{"id":"b18d8293.ceaa1","type":"change","z":"def5c4c1.d0947","name":"values2payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.values","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":80,"wires":[["27f5d0bb.200d3"]]},{"id":"a23e9796.102ba8","type":"switch","z":"def5c4c1.d0947","name":"","property":"payload.keep","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":160,"wires":[["ef3c5089.bf875"],[]]},{"id":"ef3c5089.bf875","type":"join","z":"def5c4c1.d0947","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":270,"y":160,"wires":[["606018e2.810f"]]},{"id":"606018e2.810f","type":"debug","z":"def5c4c1.d0947","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":160,"wires":[]}]