How to convert an XML file to a JSON file How to convert an XML file to a JSON file bash bash

How to convert an XML file to a JSON file


I'd suggest using xmljson lib, and code something like this:

from collections import OrderedDictfrom xmljson import BadgerFishfrom json import dumpsdef xml_to_json(xml_string):    bf = BadgerFish(dict_type=OrderedDict)    return dumps(bf.data(fromstring(xml_string)))