json to xml AttributeError: 'list' object has no attribute 'items'
mobilelifeful opened this issue · 0 comments
mobilelifeful commented
Trying to convert json to xml with object.
[
{
"meta": {
"id": "now",
"sort": "2611572000",
"section": "time",
"stesms": [
"today"
],
"booked": false
},
"hwiGx": {
"hwi": "hola",
"prsw": [
{
"sound": {
"asee": "ho001s1p"
}
}
]
},
"flff": "tion",
"defff": [
{
"sseeq": [
[
[
"sennese",
{
"dty": [
[
"test",
"{bc} hello!"
]
]
}
]
]
]
}
],
"shortcode": [
"hi!"
]
}
]
f = open('json_to_xml'.json')
sys.stdout = open('saving.xml', 'w')
print(json.dumps(xmltodict.unparse(json.load(f))))
sys.stdout.close()
which give me this error
print(json.dumps(xmltodict.unparse(json.load(f))))
File "/Users/x/miniconda3/lib/python3.9/site-packages/xmltodict.py", line 505, in unparse
for key, value in input_dict.items():
AttributeError: 'list' object has no attribute 'items'
zsh: abort python3 main.py
Thank you for any help.