Passing JSON object (as string) to python script (exec node)

#1

Hi,

I have a PLC which sends message object with json object payload. For example :

{"payload" : { "DB1" : "value" } }

I want to pass msg.payload to an exec python node as an argument. But as we can't pass object directly I was thinking about converting the msg.payload json object to a string and then passing it to the python script so that it would look like this :

python ~/scripts/process.py '{ "DB1" : "value" }'

I tried with javascript function but it must returns an object so it doesn't work.
Do you have any idea ?
Thanks

0 Likes

Passing parameter from node-red to python
#2

Hi,
The json node will convert from a string to an object and also from an object to a string. So maybe that will help ?

0 Likes