I am running the following code:
nmap = nmap3.Nmap() Os_Results = nmap.nmap_os_detection("10.100.102.34") Result_Dump = json.dumps(Os_Results) print(Result_Dump)
but statement Result_Dump returns an error (see below) while the json is valid (tested at Json_Lint).
File “/usr/local/Cellar/[email protected]/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py”, line 339, in loads
raise TypeError(f’the JSON object must be str, bytes or bytearray, ‘
TypeError: the JSON object must be str, bytes or bytearray, not dict
I have two questions:
- Why json.dumps is failing with this error msg
- Assuming I get a valid dict, How can I access the ip address from the string {“10.100.102.34”: {“osmatch”: [{“name”: “Microsoft Windows 10 1803”, “…”?
json.dump to fix the single to double qoute issue created by nmap
Daffy Duck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.