I am using the json2html package to convert JSON to HTML but I am getting the error – "fork/exec /home/sftp_user/uploads/json2html.py: exec format error"
Here is what I have done
Script is as below
#!/usr/bin/env python3
import sys
from json2html import *
from json import loads
ip = json.loads(sys.argv[1])
res = json2html.convert(json={"data":ip})
sys.stdout.write(res)
The sys.argv[1] payload is below
[ { "FirstName": "John", "LastName": "Doe", "StreetName": "120 jefferson st.", "County": "Riverside", "State": " NJ", "PostCode": 8075 }, { "FirstName": "Jack", "LastName": "McGinnis", "StreetName": "220 hobo Av.", "County": "Phila", "State": " PA", "PostCode": 9119 }, { "FirstName": "John "Da Man"", "LastName": "Repici", "StreetName": "120 Jefferson St.", "County": "Riverside", "State": " NJ", "PostCode": 8075 }, { "FirstName": "Stephen", "LastName": "Tyler", "StreetName": "7452 Terrace "At the Plaza" road", "County": "SomeTown", "State": "SD", "PostCode": 91234 }, { "FirstName": null, "LastName": "Blankman", "StreetName": null, "County": "SomeTown", "State": " SD", "PostCode": 298 }, { "FirstName": "Joan "the bone", Anne", "LastName": "Jet", "StreetName": "9th, at Terrace plc", "County": "Desert City", "State": "CO", "PostCode": 123 } ]
Error
fork/exec /home/sftp_user/uploads/json2html.py: exec format error
Any idea on what might be the issue in the code?
2
Answers
After hours of troubleshooting, found out that the script file name - "json2html.py" was causing the issue (conflicting with the package name - json2html). After changing the script file name, the script started working.
Seems that the problem with
null
value in your input JSON.Try to convert it first to
None
and then it should be fineOutput: