【发布时间】:2017-02-24 11:33:43
【问题描述】:
我有如下 JSON,它必须作为 POST 请求的正文包含,
{
"type" : "myData",
"condition" : {"projectid": 40}
}
我的 POST 请求应该如何使用 Alamofire 形成?
【问题讨论】:
标签: json swift swift3 alamofire
我有如下 JSON,它必须作为 POST 请求的正文包含,
{
"type" : "myData",
"condition" : {"projectid": 40}
}
我的 POST 请求应该如何使用 Alamofire 形成?
【问题讨论】:
标签: json swift swift3 alamofire
您只需创建参数Dictionary。
let parameters: [String:Any] = [ "type" : "myData", "condition" : ["projectid" : 40]]
现在用Alamofire 传递这个parameters 字典。
Alamofire.request(urlString, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON { response in
print(response)
}
【讨论】: