title: Correct way to retrieve json data from remote url using swift 4 for an array
body: <p>I am trying to see what is the latest and greatest way to retrieve json data in swift 4 (using Codable structure).</p>
  
  <p>I have the following json data in a remote url:</p>
  
  <pre><code>[
    {
      "products": [
          {
            "productid": "01",
            "price": "01"
          },
          {
            "productid": "02",
            "price": "02"
          }
      ]
    }
  ]
  </code></pre>
  
  <p>I have also setup the corresponding codable structure.  My questions is what would be the correct way to retrieve this data using the latest techniques for swift 4.</p>
  
  <p>I am seeing various ways such as:</p>
  
  <ul>
  <li>DataManager.getJSONFromURL ...</li>
  <li>let jsonData = try Data(contentsOf: URL ...</li>
  <li>let task = URLSession.shared.dataTask(with: url) ...</li>
  <li>try JSONSerialization.data...</li>
  </ul>
  
  <p>I would like to know which is the correct (latest) format for retrieving json data using swift 4 from a remote URL.  Thank you.</p>