我试图处理使用Alamofire从Alamofire请求的JSON响应:斯威夫特Alamofire JSON响应有括号
Alamofire.request(.POST, dbURL, parameters: ["username": username, "password": password]) .responseJSON { response in ... }
我读与
let JSONResponse = response.result.value!
响应此值返回
({keyOne = 2; k eyTwo = 4; keyThree = 2; keyFour = 6;})
而要得到这些数据,
JSONResponse.valueForKey("exampleKey")
我碰到的问题是,这并不返回简单的数据,它返回(响应都是数字,但我不能使用integerForKey的,因为显而易见的原因):
(2)
(4)
(2)
(6)
我怎样才能获得,读取和/或从该函数保存数据而不括号? 我试过使用stringByReplacingOccurencesOfString()
蛮力去除括号,但这很难看,并且不起作用。
什么是实际的json响应?你能把它粘贴在这里吗? –
并添加到Pradeep的问题,你有没有尝试反序列化JSON? – xoudini
这在swift中被称为可选。 – sector11