             
             }, completionHandler: { (result, urlResponse) -> Void in
                 
-                switch result {
-                case .Success(let data):
-                    
-                    do
-                    {
-                        let jsonObject = try NSJSONSerialization.JSONObjectWithData(data, options: [])
-                        completionHandler(result: .Success(jsonObject))
-                        
-                    } catch let error as NSError
-                    {
-                        if error.code == 3840, // Invalid JSON format, may be straight text
-                            let decodedErrorString = NSString(data: data, encoding: NSUTF8StringEncoding) {
-                            
-                                let decodedError = NSError(description: decodedErrorString as String)
-                                completionHandler(result: .Failure(decodedError))
-                            
-                        } else {
-                            completionHandler(result: .Failure(error))
-                        }
-                    }
-                    
-                    break
-                    
-                case .Failure(let error):
-                    completionHandler(result: .Failure(error))
-                    break
-                }
+            self.handleJsonTaskCompletion(result, completionHandler: completionHandler)
         })
     }
 }

        return NSURL(string: combinedPath, relativeToURL: self.baseUrl)
    }
    
    public func dataTask(configureUrlRequest configureUrlRequest : ConfigureUrlRequestHandler? = nil, completionHandler : DataTaskCompletionHandler) -> NSURLSessionDataTask? {
        
        guard let url = self.buildUrl() else {

            return nil
        }
        
        let urlRequest = self.createURLRequest(url)
        
        if let configureUrlRequest = configureUrlRequest {
            configureUrlRequest(urlRequest: urlRequest)
