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
})