title: Unexpected nil in JSON strings
body: <p>I parse JSON in my application and some of the JSONs have <code>nil</code> values which I handled. However, the app still shows me the error that JSON contains <code>nil</code> values. My code:</p>
  <pre><code>struct Response : Decodable {
  let articles: [Article]
   }
  
  struct Article: Decodable {
  
  let title: String
  let description : String
  let url : String
  let urlToImage : String
  }
  URLSession.shared.dataTask(with: url) { (data, response, error) in
       guard let data = data else { return }
       do {
       let article =  try JSONDecoder().decode(Response.self , from : data)
       for i in 0...article.articles.count - 1 {
           if type(of: article.articles[i].title) == NSNull.self {
               beforeLoadNewsViewController.titleArray.append(&quot;&quot;)
           } else {
               beforeLoadNewsViewController.titleArray.append(article.articles[i].title)
           }
  if type(of : article.articles[i].urlToImage) == NSNull.self {
                  beforeLoadNewsViewController.newsImages.append(newsListViewController.newsImages[newsListViewController.newsIndex])
  
                      } else {
                          
                          
                      let url = URL(string: article.articles[i].urlToImage ?? &quot;https://static.wixstatic.com/media/b77fe464cfc445da9003a5383a3e1acf.jpg&quot;)
                      
                          
                      let data = try? Data(contentsOf: url!)
  
                      if url != nil {
  
                      //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
                          let img = UIImage(data: data!)
                      beforeLoadNewsViewController.newsImages.append(img!)
  
                      } else {
                  beforeLoadNewsViewController.newsImages.append(newsListViewController.newsImages[newsListViewController.newsIndex])
  
                          }
  </code></pre>
  <p>This is the error running the app:</p>
  <blockquote>
  <p>FC91DEECC1631350EFA71C9C561D).description], debugDescription: &quot;Expected String value but found null instead.&quot;, underlyingError: nil))</p>
  </blockquote>
  <h3>Note:</h3>
  <p>This JSON works with other urls that don't have <code>nil</code> values.</p>
  <p>and here is the json</p>
  <pre><code>{
      &quot;status&quot;: &quot;ok&quot;,
      &quot;source&quot;: &quot;entertainment-weekly&quot;,
      &quot;sortBy&quot;: &quot;top&quot;,
      &quot;articles&quot;: [
      {
          &quot;author&quot;: null,
          &quot;title&quot;: &quot;Hollywood's Original Gone Girl&quot;,
          &quot;description&quot;: null,
          &quot;url&quot;: &quot;http://mariemcdonald.ew.com/&quot;,
          &quot;urlToImage&quot;: null,
          &quot;publishedAt&quot;: null
      },
      {
          &quot;author&quot;: &quot;Samantha Highfill&quot;,
          &quot;title&quot;: &quot;‘Supernatural’: Jensen Ackles, Jared Padalecki say the boys aren’t going ‘full-mope’&quot;,
          &quot;description&quot;: &quot;&quot;,
          &quot;url&quot;: &quot;http://ew.com/tv/2017/10/18/supernatural-jensen-ackles-jared-padalecki-season-13/&quot;,
          &quot;urlToImage&quot;: &quot;http://ewedit.files.wordpress.com/2017/10/supernatural-season-13-episode-1.jpg?crop=0px%2C0px%2C2700px%2C1417.5px&amp;resize=1200%2C630&quot;,
          &quot;publishedAt&quot;: &quot;2017-10-18T17:23:54Z&quot;
      },
      {
  </code></pre>