How to use JSON node

I want to send PLC data to NODE-RED through an IOT gateway so that I can control something as simple as a switch, generate the data value as JSON, and send it to the connected node. (Like a redis node)
I'm wondering where to connect the JSON node.

Can we connect to the function node right after the switch node, make msg.payload a global variable, and connect to the json node?

If I connect a redis node behind a json node to send data, will it be sent as json?
Let me know if I'm wrong or need to be careful.

I'm sorry for my English

How are sending the data to/through the IOT gateway? MQTT?

I can't see any MQTT nodes.

The JSON node is sort of used to construct a JSON message. (Or decode deconstruct one).

I am guessing the input from your IOT is where the inject node is?

You mention a switch you want to control.
The terms used are not clear.
So you mean the switch node I can see or are you calling the gate node a switch?

So depending on HOW you are sending the messages you may not need one.

I believe that REDIS is a key/value database. As such, it will only be able to store a simple value as text unless you use an extension to REDIS which I'm guessing the REDIS node would not support?

To store as text, assuming you have the data as a JavaScript object on msg.payload, simply send it through a JSON node before sending to REDIS.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.