title: How to parse JSON in Swift using NSURLSession
body: <p>I am trying to parse JSON but getting this error:</p>
  
  <blockquote>
    <p>type of expression is ambiguous without more context</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>func jsonParser() {
  
      let urlPath = "http://headers.jsontest.com/"
      let endpoint = NSURL(string: urlPath)
      let request = NSMutableURLRequest(URL:endpoint!)
  
      let session = NSURLSession.sharedSession()
      NSURLSession.sharedSession().dataTaskWithRequest(request){ (data, response, error) throws -&gt; Void in
  
          if error != nil {
              print("Get Error")
          }else{
              //var error:NSError?
              do {
                  let json:AnyObject =  try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(rawValue: 0)) as? NSDictionary
  
              print(json)
  
          } catch let error as NSError {
              // error handling
              print(error?.localizedDescription)
          }
          }
      }
      //task.resume()
  }
  </code></pre>
  
  <p>This is working fine with out try catch in Xcode 6.4 but this is not working in Xcode 7.</p>