title: Json Serialisation Swift 3
body: <p>I am trying to serialise the json in the code below, the logs print out the display names successfully but I get a crash with an error:</p>
  
  <blockquote>
    <p>fatal error: unexpectedly found nil while unwrapping an Optional value</p>
  </blockquote>
  
  <p>on the following lines:</p>
  
  <blockquote>
    <p>print(item["display-name"]! as!String)</p>
    
    <p>Blockquoteself.tableData.append(item["display-name"] as! String)</p>
  </blockquote>
  
  <p>I can't seem to figure out why, any help much appreciated!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  let url = NSURL(string: "https://www.asmserver.co.uk/sally/parsexml.php")!
          
          let task = URLSession.shared.dataTask(with: url as URL) { (data, response, error) -&gt; Void in
              
              
              
              if let urlContent = data {
                  
                  
                  
                  do {
                      
                      
                      
                      if let jsonResult = try JSONSerialization.jsonObject(with: urlContent, options: []) as? [[String:AnyObject]] {
                          
                          
                          
                              for item in jsonResult {
                              
                             
                             print(item["display-name"]! as!String)
                       
                              self.tableData.append(item["display-name"] as! String)
                              
                          
                          }
                          
                      }
                      
                  } catch {
                      
                      print("JSON serialization failed")
                      
                  }
                  
                  
              } else {
                  
                  print("ERROR FOUND HERE")
              }
              
              
              DispatchQueue.main.async(execute: { () -&gt; Void in
                  
                  self.tableView.reloadData()
                  
              })
              
              self.tableView.isUserInteractionEnabled = true
              
              
          }
          
          task.resume()</code></pre>
  </div>
  </div>
  </p>