I am seeing a formatting error for JSON due to the use of single quote instead of double quote.
test scenario using Google 8.8.8.8 so you can possibly replicate the issue. I have done this on my own IP addresses, but I wanted to keep that info private as you can likely understand.
import nmap3
import pprint
pp = pprint.PrettyPrinter(indent=4)
nmap = nmap3.Nmap()
services = nmap.nmap_version_detection("8.8.8.8")
pp.pprint(services)
results are below. I am having various issues parsing the information so that I can write to a database, json file, conver to yaml etc..
For the results that i have below, my editor shows 138 errors.
{ '8.8.8.8': { 'hostname': [{'name': 'dns.google', 'type': 'PTR'}],
'macaddress': None,
'osmatch': {},
'ports': [ { 'portid': '53',
'protocol': 'tcp',
'reason': 'syn-ack',
'reason_ttl': '0',
'scripts': [],
'service': { 'conf': '8',
'method': 'probed',
'name': 'tcpwrapped'},
'state': 'open'},
{ 'portid': '443',
'protocol': 'tcp',
'reason': 'syn-ack',
'reason_ttl': '0',
'scripts': [],
'service': { 'conf': '10',
'method': 'probed',
'name': 'https',
'product': 'HTTP server '
'(unknown)',
'servicefp': 'SF-Port443-TCP:V=7.92%T=SSL%I=7%D=9/10%Time=613BB98E%P=x86_64-apple-darwin17.7.0%r(GetRequest,2C9,"HTTP/1\\.0\\x20302\\x20Found\\r\\nAccess-Control-Allow-Origin:\\x20\\*\\r\\nX-Content-Type-Options:\\x20nosniff\\r\\nLocation:\\x20https://dns\\.google/\\r\\nDate:\\x20Fri,\\x2010\\x20Sep\\x202021\\x2020:01:18\\x20GMT\\r\\nContent-Type:\\x20text/html;\\x20charset=UTF-8\\r\\nServer:\\x20HTTP\\x20server\\x20\\(unknown\\)\\r\\nContent-Length:\\x20216\\r\\nX-XSS-Protection:\\x200\\r\\nX-Frame-Options:\\x20SAMEORIGIN\\r\\nAlt-Svc:\\x20h3=\\":443\\";\\x20ma=2592000,h3-29=\\":443\\";\\x20ma=2592000,h3-T051=\\":443\\";\\x20ma=2592000,h3-Q050=\\":443\\";\\x20ma=2592000,h3-Q046=\\":443\\";\\x20ma=2592000,h3-Q043=\\":443\\";\\x20ma=2592000,quic=\\":443\\";\\x20ma=2592000;\\x20v=\\"46,43\\"\\r\\n\\r\\n<HTML><HEAD><meta\\x20http-equiv=\\"content-type\\"\\x20content=\\"text/html;charset=utf-8\\">\\n<TITLE>302\\x20Moved</TITLE></HEAD><BODY>\\n<H1>302\\x20Moved</H1>\\nThe\\x20document\\x20has\\x20moved\\n<A\\x20HREF=\\"https://dns\\.google/\\">here</A>\\.\\r\\n</BODY></HTML>\\r\\n")%r(HTTPOptions,2A9,"HTTP/1\\.0\\x20302\\x20Found\\r\\nX-Content-Type-Options:\\x20nosniff\\r\\nLocation:\\x20https://dns\\.google/\\r\\nDate:\\x20Fri,\\x2010\\x20Sep\\x202021\\x2020:01:18\\x20GMT\\r\\nContent-Type:\\x20text/html;\\x20charset=UTF-8\\r\\nServer:\\x20HTTP\\x20server\\x20\\(unknown\\)\\r\\nContent-Length:\\x20216\\r\\nX-XSS-Protection:\\x200\\r\\nX-Frame-Options:\\x20SAMEORIGIN\\r\\nAlt-Svc:\\x20h3=\\":443\\";\\x20ma=2592000,h3-29=\\":443\\";\\x20ma=2592000,h3-T051=\\":443\\";\\x20ma=2592000,h3-Q050=\\":443\\";\\x20ma=2592000,h3-Q046=\\":443\\";\\x20ma=2592000,h3-Q043=\\":443\\";\\x20ma=2592000,quic=\\":443\\";\\x20ma=2592000;\\x20v=\\"46,43\\"\\r\\n\\r\\n<HTML><HEAD><meta\\x20http-equiv=\\"content-type\\"\\x20content=\\"text/html;charset=utf-8\\">\\n<TITLE>302\\x20Moved</TITLE></HEAD><BODY>\\n<H1>302\\x20Moved</H1>\\nThe\\x20document\\x20has\\x20moved\\n<A\\x20HREF=\\"https://dns\\.google/\\">here</A>\\.\\r\\n</BODY></HTML>\\r\\n")%r(FourOhFourRequest,307,"HTTP/1\\.0\\x20302\\x20Found\\r\\nAccess-Control-Allow-Origin:\\x20\\*\\r\\nX-Content-Type-Options:\\x20nosniff\\r\\nLocation:\\x20https://dns\\.google/nice%20ports%2C/Trinity\\.txt\\.bak\\r\\nDate:\\x20Fri,\\x2010\\x20Sep\\x202021\\x2020:01:18\\x20GMT\\r\\nContent-Type:\\x20text/html;\\x20charset=UTF-8\\r\\nServer:\\x20HTTP\\x20server\\x20\\(unknown\\)\\r\\nContent-Length:\\x20247\\r\\nX-XSS-Protection:\\x200\\r\\nX-Frame-Options:\\x20SAMEORIGIN\\r\\nAlt-Svc:\\x20h3=\\":443\\";\\x20ma=2592000,h3-29=\\":443\\";\\x20ma=2592000,h3-T051=\\":443\\";\\x20ma=2592000,h3-Q050=\\":443\\";\\x20ma=2592000,h3-Q046=\\":443\\";\\x20ma=2592000,h3-Q043=\\":443\\";\\x20ma=2592000,quic=\\":443\\";\\x20ma=2592000;\\x20v=\\"46,43\\"\\r\\n\\r\\n<HTML><HEAD><meta\\x20http-equiv=\\"content-type\\"\\x20content=\\"text/html;charset=utf-8\\">\\n<TITLE>302\\x20Moved</TITLE></HEAD><BODY>\\n<H1>302\\x20Moved</H1>\\nThe\\x20document\\x20has\\x20moved\\n<A\\x20HREF=\\"https://dns\\.google/nice%20ports%2C/Trinity\\.txt\\.bak\\">here</A>\\.\\r\\n</BODY></HTML>\\r\\n");',
'tunnel': 'ssl'},
'state': 'open'}],
'state': { 'reason': 'syn-ack',
'reason_ttl': '0',
'state': 'up'}},
'runtime': { 'elapsed': '70.81',
'exit': 'success',
'summary': 'Nmap done at Fri Sep 10 15:02:11 2021; 1 IP '
'address (1 host up) scanned in 70.81 seconds',
'time': '1631304131',
'timestr': 'Fri Sep 10 15:02:11 2021'},
'stats': { 'args': '/usr/local/bin/nmap -oX - -sV 8.8.8.8',
'scanner': 'nmap',
'start': '1631304060',
'startstr': 'Fri Sep 10 15:01:00 2021',
'version': '7.92',
'xmloutputversion': '1.05'}}