Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios HTTP POST Json格式和set Alamofire_Ios_Json_Swift_Alamofire - Fatal编程技术网

Ios HTTP POST Json格式和set Alamofire

Ios HTTP POST Json格式和set Alamofire,ios,json,swift,alamofire,Ios,Json,Swift,Alamofire,格式转换为此 ["client_ID": "0", "username": "asdf@gmail.com", "grant_type": "password", "password": "12345", "client_secret": "xxxxxxxxxxxxxxxxxxxxx", "scope": "adfs.user"] 您可以尝试以下方法: {"client_ID": "2", "username": "asdf@gmail.com", "grant_type": "passwor

格式转换为此

["client_ID": "0", "username": "asdf@gmail.com", "grant_type": "password", "password": "12345", "client_secret": "xxxxxxxxxxxxxxxxxxxxx", "scope": "adfs.user"]
您可以尝试以下方法:

{"client_ID": "2", "username": "asdf@gmail.com", "grant_type": "password", "password": "12345", "client_secret": "xxxxxxxxxxxxxxxxxxxxx", "scope": "adfs.user"}

问题是什么?让postString:Parameters=[“grant\u type”:grant\u type,“client\u ID”:client\u ID,“client\u secret”:client\u secret,“username”:emailString,“password”:passwordString,“scope”:ROLE]很抱歉,我们没有理解这个问题。你到底想达到什么目的?您正在尝试将
字典
转换为JSON字符串吗?Alamofire可以在发送数据时将Swift字典转换为JSON字典。你试过什么吗?在lib的自述中,有示例、解释等。
let params: Parameters = [ "grant_type" : GRANT_TYPE ,"client_ID" : CLIENT_ID ,"client_secret" : CLIENT_SECRET,"username" : emailString, "password" : passwordString,"scope" : ROLE] 
let req = Alamofire.request(url, method: .post, parameters: params, encoding:JSONEncoding.default , headers: nil).validate().responseJSON { (response) in

})