【发布时间】:2018-10-15 06:17:10
【问题描述】:
我正在使用Alamofire 在外部 API 上调用 .put 方法。在 Postman 中,我可以按以下格式成功传递原始 JSON 数据,其中每个项目都包含一个 ID 和一个数量。 :
[{
"id":"176",
"quantity":"2"
}, {
"id":"178",
"quantity":"1"
}]
cURL 示例:
PUT /cart HTTP/1.1
Host: someapi.biz
x-api-key: somekey
x-auth-token: sometoken
Content-Type: application/json
cache-control: no-cache
Postman-Token: sometoken
[{
"id":"176",
"quantity":"2"
}, {
"id":"178",
"quantity":"1"
}]------WebKitFormBoundary7MA4YWxkTrZu0gW--
我不知道如何将这些信息正确地格式化为 Alamofire 的一组参数。
for item in OrderedItems {
let rowItem: JSON = ["id" : item.ID, "quantity" : item.Quantity]
??
}
【问题讨论】:
-
对于相同的参数键,您要发送然后使用Alomofire的多部分格式。
标签: ios json swift parameters alamofire