请求 Alamofire
Posted
技术标签:
【中文标题】请求 Alamofire【英文标题】:Request to Alamofire 【发布时间】:2018-09-13 06:49:08 【问题描述】:我需要像这样向服务器发送请求
[
"Case":"add",
"Table":"user",
"Field":["Email","Password"],
"Value":["a","a"],
"Duplicate":["Email"],
"SecureEncrpt":"Password",
"SecureDecrpt":"Password"
]
我正在使用 alamofire 进行网络进程,并且我使用这样的请求结构
let loginparas = [
"Case": "add",
"Table":"user",
"Field":["Email","Password"],
"Value":[details,pass],
"Duplicate":["Email"],
"SecureEncrpt":"",
"SecureDecrpt":""
] as AnyObject
let parameters = loginparas as! Parameters
我怎样才能得到完全一样的格式?
【问题讨论】:
您可以将键值作为参数发送 您提到的请求数据包是对象数组而不是键值对(字典) 【参考方案1】:let loginparas = [
"Case": "add",
"Table":"user",
"Field":["Email","Password"],
"Value":[details,pass],
"Duplicate":["Email"],
"SecureEncrpt":"",
"SecureDecrpt":""
] as [String:Any]
Alamofire.request( url , method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers ).responseJSON response in
if response.result.isSuccess
guard let json = response.result.value as? NSArray else return
for j in json
let jsonValur = j as? [String:Any]
let case = jsonValue["Case"] as? String
...
...
...
【讨论】:
以上是关于请求 Alamofire的主要内容,如果未能解决你的问题,请参考以下文章