Alamofire Get Request and JSON Response Alamofire Get Request and JSON Response json json

Alamofire Get Request and JSON Response


Alamofire request have several method for handle response. Try to handle data response and convert it to String. Confirm that response JSON is normal.

Alamofire.request(.GET, url!).response { (_, _, data, error) in    let str = NSString(data: data, encoding: NSUTF8StringEncoding)    println(str)    println(error)}

Also checkout error while parsing JSON data.


For some reason it's an issue I've too with the Alamofire request for JSON. It is the way I handle the JSON requests using Alamofire :

Alamofire.request(.GET, urlTo, parameters: nil, encoding: .URL).responseString(completionHandler: {        (request: NSURLRequest, response: NSHTTPURLResponse?, responseBody: String?, error: NSError?) -> Void in        // Convert the response to NSData to handle with SwiftyJSON        if let data = (responseBody as NSString).dataUsingEncoding(NSUTF8StringEncoding) {            let json = JSON(data: data)            println(json)        }})

I strongly recommend you using SwiftyJSON to manage the JSON in a better and easy way, it's up to you.

I hope this help you.