我正在使用Web服务和python请求模块。我收到错误,我的文件不可序列化。
我的错误是; TypeError:不是JSON可序列化的
我的json文件是本地文件,其中包含我请求的数据。
import requests
from json import JSONEncoder
import json
f = open('C:\Users\Administrator\Desktop\myla311.json', 'r')
url = "myURL"
headers = {'Content-type': 'raw', 'Accept': '/'}
response = requests.post(url, data=json.load(f), headers=headers)
f.close()
print response.text
print response
我的预期输出
{
"MetaData": {},
"RequestSpecificDetail": {
"ParentSRNumberForLink": ""
},
"SRData": {
"Anonymous": "Y",
"Assignee": "",
"CreatedByUserLogin": "",
"CustomerAccessNumber": "",
"LADWPAccountNo": "",
"Language": "English",
"ListOfLa311GisLayer": {},
"ListOfLa311ServiceRequestNotes": {
"La311ServiceRequestNotes": [
{
"Comment": "hxhdudi",
"CommentType": "Feedback",
"FeedbackSRType": "Weed Abatement for Pvt Parcels",
"IsSrNoAvailable": "N"
},
{
"Comment": "",
"CommentType": "External",
"CreatedByUser": "",
"IsSrNoAvailable": "N"
}
]
},
"LoginUser": "",
"MobilOS": "Android",
"NewContactEmail": "",
"NewContactFirstName": "",
"NewContactLastName": "",
"NewContactPhone": "",
"Owner": "Other",
"ParentSRNumber": "",
"Priority": "Normal",
"SRCommunityPoliceStation": "RAMPART",
"SRType": "Feedback",
"ServiceDate": "01/22/2015",
"Source": "Mobile App",
"Status": "Open",
"UpdatedByUserLogin": ""
}
}
答案 0 :(得分:1)