我使用json.dumps将字典列表加载到JSON对象中。我的输出类似于:[
{
"MetaData": {},
"SRData": {
"ListOfLa311DeadAnimalRemoval": {
"DeadAnimalRemoval": [
{
"DACItemCount": "0",
"DACType": " ",
"DriverFirstName": "SA",
"DriverLastName": "Aguilar",
"LastUpdatedBy": "SANSTAR1",
"Name": "070920151119458601",
"Type": "Dead Animal Removal"
},
{
"DACType": " ",
"DriverFirstName": "SA",
"DriverLastName": "Aguilar",
"LastUpdatedBy": "SANSTAR1",
"Type": "Dead Animal Removal"
}
]
},
"ReasonCode": "",
"ResolutionCode": "A",
"SRNumber": "1-20979881"
}
}
]
如何成功删除JSON对象开头和结尾的括号?
附加词典和列表的代码:dL311 = dict()
dL311.setdefault("DeadAnimalRemoval", l311)
dResult.setdefault("ListOfLa311DeadAnimalRemoval",dL311)
#Ends of adding additional itmes ****************************************
lResults.append({"MetaData": {}, "SRData": dResult})
ii = ii + 1
print(json.dumps(lResults, sort_keys=True, indent=4))