【发布时间】:2015-04-10 21:43:42
【问题描述】:
我正在使用网络服务和 python 请求模块。我收到错误我的文件不可序列化。
我的错误是; TypeError: is not JSON serializable
我的 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": ""
}
}
【问题讨论】:
-
你遇到了什么错误?
-
你为什么要导入
json三次?? -
@ForceBru:确定一下?
-
你永远不会有足够的
jsons -
@runDOSrun,是的。我们需要更多
json的!
标签: python json serialization