-2
我正在使用網絡服務和python請求模塊。我收到錯誤,我的文件不可序列化。JSON不可序列化
我的錯誤是; 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": ""
}
}
什麼錯誤你好嗎? – 2015-02-10 18:13:09
你爲什麼要導入'json' **三次**? – ForceBru 2015-02-10 18:13:13
@ForceBru:可以肯定嗎? – 2015-02-10 18:13:48