Not able to parse JSON with NSJSONSerialization

Not able to parse JSON receiving error NSCocoaErrorDomain Code=3840
My JSON is properly validated and is utf-8 encoded. I am using this code

let request: NSURLRequest = NSURLRequest(URL: url)

        let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data: NSData?, response: NSURLResponse?, error: NSError?) -> Void in
            print(data)

            do {
                let jsonDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options:[NSJSONReadingOptions()]) as? [String: AnyObject]
                print(jsonDictionary)

            } catch {
                print(error)
            }

        })
        dataTask?.resume()


Source: ios

Leave a Reply