json - 发送 Alamofire JSON 数组 Swift

标签 json swift alamofire swifty-json

我需要用这个正文发送请求:

[{"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/

相关文章:

mysql - 如何使用 codeigniter 从 json 列中检索数据?

ios - 无法让 iOS MapKit Annotation 显示标题和副标题

ios - UserDefaults 自动登录不起作用

ios - 模块 'Alamofire' 是为不兼容的目标 arm64 - apple- ios 10 创建的

ios - Apple 拒绝我的应用程序,称内容无法在 ipv6 网络中加载

c# - JSON 反序列化对象 HTTPWebResponse

ruby-on-rails - 在 rails 中将部分 pg 数据库条目作为 JSON 返回

java - 如何访问 JsonPropertyOrder

ios - 从嵌套 json 数组获取数据时出现问题

ios - RequestRetrier Alamofire 锁不工作