我有一个包含多个JSON对象的列表,我想将这些JSON对象组合成一个json对象,我尝试使用jsonmerge但没有运气.
我的清单是:
t = [{'ComSMS': 'true'}, {'ComMail': 'true'}, {'PName': 'riyaas'}, {'phone': '1'}]
Run Code Online (Sandbox Code Playgroud)
期望的输出是
t = [{'ComSMS': 'true', 'ComMail': 'true', 'PName': 'riyaas', 'phone': '1'}]
Run Code Online (Sandbox Code Playgroud)
我把列表放在for循环中并尝试json合并,我得到了错误 head missing expected 2 arguments got 1
有人可以帮我解决这个问题
Avi*_*Raj 10
你可能会喜欢这样,但它不应该是有序的.
>>> t = [{'ComSMS': 'true'}, {'ComMail': 'true'}, {'PName': 'riyaas'}, {'phone': '1'}]
>>> [{i:j for x in t for i,j in x.items()}]
[{'ComSMS': 'true', 'phone': '1', 'PName': 'riyaas', 'ComMail': 'true'}]
Run Code Online (Sandbox Code Playgroud)