Remove "{ }" from payload

So there's three options on how to do this.... I just put together a sample flow to show they all give exactly the same result.

[{"id":"30adbf39.74344","type":"inject","z":"6d1914f5.165c5c","name":"","topic":"","payload":"{12.8}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":126.5,"y":177,"wires":[["605798e1.c64338","cbff28e3.cce978","f941b127.ec0f6"]]},{"id":"99637a8d.d5d28","type":"debug","z":"6d1914f5.165c5c","name":"JSONata output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":580.5,"y":178,"wires":[]},{"id":"605798e1.c64338","type":"function","z":"6d1914f5.165c5c","name":"With a function node","func":"msg.payload = msg.payload.substring(1, msg.payload.length - 1)\nreturn msg;","outputs":1,"noerr":0,"x":326.5,"y":239,"wires":[["55e0f225.0010e4"]]},{"id":"55e0f225.0010e4","type":"debug","z":"6d1914f5.165c5c","name":"Function node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":597.5,"y":239,"wires":[]},{"id":"cbff28e3.cce978","type":"change","z":"6d1914f5.165c5c","name":"With JSONata","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substring(payload, 1, $length(payload) - 2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":308.5,"y":177,"wires":[["99637a8d.d5d28"]]},{"id":"f941b127.ec0f6","type":"change","z":"6d1914f5.165c5c","name":"With change node/search & replace","rules":[{"t":"change","p":"payload","pt":"msg","from":"{","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"}","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310.5,"y":335,"wires":[["39e2d6eb.e6e86a"]]},{"id":"39e2d6eb.e6e86a","type":"debug","z":"6d1914f5.165c5c","name":"Change node search/replace output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":661.5,"y":336,"wires":[]}]
1 Like