I’m trying to use the JSON Reader and the Python script node to convert a JSON file to sdf. I am using the script below in the Python script node:
import json
Load the JSON data from the input port
input_data = inputs[0].get_data()
json_data = json.loads(input_data[0][0])
Extract the relevant information from the JSON data
sdf_data = “Header\n\n”
for item in json_data:
sdf_data += “Item {\n”
sdf_data += " name: " + item[“name”] + “\n”
sdf_data += " value: " + item[“value”] + “\n”
sdf_data += “}\n”
Write the SDF data to the output port
outputs[0].set_data([[sdf_data]])
And I get the following error:
Executing the Python script failed: Traceback (most recent call last):
File “”, line 4, in
NameError: name ‘inputs’ is not defined