Skip to content

Instantly share code, notes, and snippets.

@savon-noir
Created May 3, 2013 11:32
Show Gist options
  • Save savon-noir/5508603 to your computer and use it in GitHub Desktop.
Save savon-noir/5508603 to your computer and use it in GitHub Desktop.
from libnmap import NmapParser, NmapReport
from libnmap import ReportDecoder, ReportEncoder
import json
d = NmapParser.parse_fromfile('/root/dev/python-nmap-lib/libnmap/test/files/1_hosts.xml')
r = NmapReport('t1', d)
# create a json object from an NmapReport instance
j = json.dumps(r, cls=ReportEncoder)
# create a NmapReport instance from a json object
nmapreport = json.loads(j, cls=ReportDecoder)
nmapreport.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment