【问题标题】:Send Alamofire JSON Array Swift发送 Alamofire JSON 数组 Swift
【发布时间】:2016-07-01 19:49:32
【问题描述】:

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

[{"uid":777}]

我如何使用 Alamofire 和 SwiftyJSON 来做到这一点

【问题讨论】:

    标签: json swift alamofire swifty-json


    【解决方案1】:

    在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2015-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多