我正在使用Alamofire进行网络连接,使用SwiftyJSON来解析我的 iOS 应用程序中的服务器响应。
我总是unknown
在尝试这样做时得到println(JSON(data!))
这是我的请求代码:
Alamofire.request(.GET, URLString: "http://httpbin.org/get", parameters: ["foo": "bar"])
.response { (request, response, data, error) in
println("request ==== \(request)")
println("response ==== \(response)")
println("error ==== \(error)")
println("json ==== \(JSON(data!))")
println("data ==== \(data)")
}
这是我的控制台输出:
request ==== <NSMutableURLRequest: 0x15e9a4e0> { URL: http://httpbin.org/get?foo=bar }
response ==== Optional(<NSHTTPURLResponse: 0x15ddc910> { URL: http://httpbin.org/get?foo=bar } { status code: 200, headers {
"Access-Control-Allow-Credentials" = true;
"Access-Control-Allow-Origin" = "*";
Connection = "keep-alive";
"Content-Length" = 430;
"Content-Type" = "application/json";
Date = "Wed, 04 Feb 2015 09:12:45 GMT";
Server = nginx;
} })
error ==== nil
json ==== unknown
data ==== Optional(<7b0a2020 22617267 73223a20 7b0a2020 20202266 6f6f223a 20226261 72220a20 207d2c20 0a202022 68656164 65727322 3a207b0a 20202020 22416363 65707422 3a20222a 2f2a222c 200a2020 20202241 63636570 742d456e 636f6469 6e67223a 2022677a 69703b71 3d312e30 2c636f6d 70726573 733b713d 302e3522 2c200a20 20202022 41636365 70742d4c 616e6775 61676522 3a202266 723b713d 312e302c 656e3b71 3d302e39 2c64653b 713d302e 382c7a68 2d48616e 733b713d 302e372c 7a682d48 616e743b 713d302e 362c6a61 3b713d30 2e35222c 200a2020 20202248 6f737422 3a202268 74747062 696e2e6f 7267222c 200a2020 20202255 7365722d 4167656e 74223a20 224f7545 73744d6f 6e43616d 696f6e2f 636f6d2e 50697865 6c734163 6164656d 792e4f75 4573744d 6f6e4361 6d696f6e 2028313b 204f5320 56657273 696f6e20 372e312e 32202842 75696c64 20313144 32353729 29220a20 207d2c20 0a202022 6f726967 696e223a 20223139 372e3134 2e31302e 3234222c 200a2020 2275726c 223a2022 68747470 3a2f2f68 74747062 696e2e6f 72672f67 65743f66 6f6f3d62 6172220a 7d0a>)
难道我做错了什么?