Parameters 如何将字典作为参数发送到Alamofire,swift 3

Parameters 如何将字典作为参数发送到Alamofire,swift 3,parameters,get,swift3,nsdictionary,alamofire,Parameters,Get,Swift3,Nsdictionary,Alamofire,我想发送以下参数 {"serial_number":{"type":"match", "value":"somevalue"}} 所以我试着这样做 let parameters : [String:AnyObject] = [ "serial_number":[ "type":"match", "value":serialNum ] ] Alamofire.req

我想发送以下参数

{"serial_number":{"type":"match", "value":"somevalue"}}
所以我试着这样做

 let parameters : [String:AnyObject] = [
            "serial_number":[
                "type":"match",
                "value":serialNum
            ]
        ]
Alamofire.request(.GET, Constant.WebClient.Cool + "/creator/" + cid + "/wa?filling=", parameters: nil, headers: headers)
            .responseJSON { response in

                switch response.result {
                case.Success(let JSON):
                    print("get json is success")
                    if JSON["status"] != nil && JSON["status"] as! String == "fail"{
                        print("some error occured")
                    }
                    else{
                        let resultArray = JSON as! NSArray
                        print("\(resultArray)")
                    }
                    break
                case .Failure(let error):
                    print("request failed with error : \(error.localizedDescription)")

                }

        }
然后像这样“得到”

 let parameters : [String:AnyObject] = [
            "serial_number":[
                "type":"match",
                "value":serialNum
            ]
        ]
Alamofire.request(.GET, Constant.WebClient.Cool + "/creator/" + cid + "/wa?filling=", parameters: nil, headers: headers)
            .responseJSON { response in

                switch response.result {
                case.Success(let JSON):
                    print("get json is success")
                    if JSON["status"] != nil && JSON["status"] as! String == "fail"{
                        print("some error occured")
                    }
                    else{
                        let resultArray = JSON as! NSArray
                        print("\(resultArray)")
                    }
                    break
                case .Failure(let error):
                    print("request failed with error : \(error.localizedDescription)")

                }

        }
但对我不起作用。如何获得

{"serial_number":{"type":"match", "value":"someval"}}
查字典。希望你能帮上忙。当我试着打印字典时,它是如下所示的

["serial_number": {
    type = match;
    value = "some val";
}]

希望您能提供帮助。

alamofire请求使用默认编码,即
URLEncoding。默认编码在本例中无法按预期工作,因此您必须将编码更改为
JSONEncoding(选项:[])

遵循文件: