Convert XML to JSON#
Python’s standard library has several modules for parsing XML (including DOM, SAX, and ElementTree). As of Python 2.6, support for converting Python data structures to and from JSON is included in the json module.
json module can actually dump the
For example you a variable
>>>> type(router_config) <class 'lxml.etree._Element'>
To dump into a variable:
config_json = json.dumps(router_config)
To dump into a file: