我需要用这个正文发送请求:
[{"uid":777}]
我如何使用 Alamofire 和 SwiftyJSON 做到这一点
最佳答案
发现于 Alamofire 的 own GitHub readme :
let parameters = [
"foo": [1,2,3],
"bar": [
"baz": "qux"
]
]
Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON)
// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}
所以我猜你会按如下方式编写要发送的数据:
let dataToSend = ["uid":"777"] // or more brackets if you want an Array of Dictionaries
关于json - 发送 Alamofire JSON 数组 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38153010/