title: JSON Parsing - What are the alternate ways without URL Session task resume as it is not part of the main thread?
body: <p>I am new to <code>Swift</code>. For <code>JSON</code> parsing from APIs, I found the below code.</p>
  
  <pre><code>guard let url = URL(string: "url path here") else {return}
  
  let task = URLSession.shared.dataTask(with: url)
  {
      (data, response, error) in
      guard let dataResponse = data,
          error == nil else
      {
          print(error?.localizedDescription ?? "Response Error")
          return
      }
      do
      {
          //json response will be received here
          let jsonResponse = try JSONSerialization.jsonObject(with: dataResponse, options: []) as! [String : Any]
          print(jsonResponse)
  
  
      }
      catch let parsingError
      {
          print("Error", parsingError)
      }
  }
  task.resume()
  </code></pre>
  
  <p>Why do we need to use <code>task.resume()</code>. Is there any other way to get the <code>JSON</code> response without the above code.</p>