node red payload json
时间: 2023-07-07 10:07:10 浏览: 202
在 Node-RED 中,payload 是指消息中的数据部分。如果您将 JSON 数据放入消息的 payload 中,则可以使用 JSON 节点来解析它。
以下是一个简单的示例流程,其中使用 JSON 节点来解析包含 JSON 数据的 payload:
```
[{"id":"e24c4c35.6f02a8","type":"inject","z":"a24b4b45.2c455","name":"Inject JSON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"name\":\"John\",\"age\":30,\"city\":\"New York\"}","payloadType":"json","x":170,"y":220,"wires":[["7d73938f.9f5a0c"]]},{"id":"7d73938f.9f5a0c","type":"json","z":"a24b4b45.2c455","name":"","property":"payload","action":"","pretty":false,"x":390,"y":220,"wires":[["3d6716c1.1c4d78"]]},{"id":"3d6716c1.1c4d78","type":"debug","z":"a24b4b45.2c455","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":220,"wires":[]}]
```
在这个流程中,注入节点将包含 JSON 数据的消息发送到 JSON 节点。JSON 节点将解析 JSON 数据,并将其放入消息的 payload 中。最后,调试节点显示解析的 JSON 数据。
阅读全文