I'm trying to convert xml to json in python using xmltodict
library. Though, the xml is getting converted to json, before every key in dict, '@' is getting prefixed. Below is the code snippet and sample output:
import xmltodict
import json
with open('response.xml','r') as res_file:
doc = xmltodict.parse(res_file.read())
xml_json_str = json.dumps(doc)
final_json = json.loads(xml_json_str)
Output:
"CustomerInfo": {
"@address": "Bangalore, Karnataka 560034",
"@email": "abc@gmail.com",
"@name": "Sam",
}
How to remove @ from all key's at one go?