I have seen many topics in here about getting a json input into an exec call for python but a lot of the posts end before the answer is ever found.
I have several python calls I intend to make in the node red dashboard, that will take in static JSON objects. To do this, I created a "TEMPLATE" node, which houses my json data.
In order to get the data prepped for the exec call, I have the TEMPLATE format set to "Plain Text", and output as "Parsed JSON". I then send this to a JSON node. Lastly, this is sent to my exec call.
I append the msg.payload to the exec call and printing it as:
import sys print(sys.argv)
The issue is, sys.argv will strip the quotations off of my json object, so I cannot load it as json. I saw in another post someone mentioning using ARGPARSER instead, however, I do not know how to add an arguement using the EXEC node in node-red.
Here is an output from my python script where you can see "controls" has no quotations and so on.
So my questions are:
Is there a way to read in JSON in a python script from the exec node with the quotations intact without using an argparser?
If "1" is not possible, how can I use argparser with the exec node. i.e. how do I add named parameters to the exec node