please find the node-red code below:
[
{
"id": "1ff7a51a41da7b57",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7cb19c907c1ff65c",
"type": "inject",
"z": "1ff7a51a41da7b57",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"foo\": \"bar\", \"baz\": 42}",
"payloadType": "str",
"x": 190,
"y": 160,
"wires": [
[
"7bfbe73e74b613d2"
]
]
},
{
"id": "410e2cc3223cf46c",
"type": "debug",
"z": "1ff7a51a41da7b57",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 640,
"y": 160,
"wires": []
},
{
"id": "7bfbe73e74b613d2",
"type": "exec",
"z": "1ff7a51a41da7b57",
"command": "python D:\\PythonCode\\hello.py",
"addpay": "",
"append": "",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "",
"x": 410,
"y": 160,
"wires": [
[
"410e2cc3223cf46c"
],
[],
[]
]
}
]
And my python code-
import json
import sys
# Read the JSON object from the command-line argument
json_string = sys.argv[1]
# Parse the JSON object into a Python object
json_obj = json.loads(json_string)
# Access the properties of the JSON object
foo_value = json_obj["foo"]
baz_value = json_obj["baz"]
# Print the values to the console
print(f"foo = {foo_value}")
print(f"baz = {baz_value}")