title: Swift and JSON driving me crazy
body: <p>I am really getting stuck on this.
  I have created a JSON service, that returns data like this:</p>
  
  <pre><code>[
      {
          "docNameField": "Test",
          "docNumField": 22832048,
          "docVerField": 1,
          "docDataBaseField": "Legal",
          "docCheckedOutWhenField": "03/05/2020",
          "whereCheckedOutField": "PC0X8J9RD"
      }
  ]
  </code></pre>
  
  <p>This is Postman output.</p>
  
  <p>No matter how I try, I cannot seem to be able to put together the correct combination og HTTP call, deserialization, types and so on to get a list of objects out in the end.</p>
  
  <p>This func below outputs this:</p>
  
  <blockquote>
    <p>JSON String: Optional("[{\"docNameField\":\"Test\",\"docNumField\":22832048,\"docVerField\":1,\"docDataBaseField\":\"Legal\",\"docCheckedOutWhenField\":\"03/05/2020\",\"whereCheckedOutField\":\"PC0X8J9RD\"}]")</p>
  </blockquote>
  
  <pre><code>func LoadLockedDocumentsByDocnum(docNum:Int32) {
      let json: [String: Any] = ["action":"getCheckedOutDocuments","adminUserName":"\(APPuserName)","adminPassword":"\(APPuserPassword)","adminDomain":"\(APPuserDomain)","applicationKey":"19730905{testKey}","searchTerm":docNum]
             let jsonData = try? JSONSerialization.data(withJSONObject: json)
      self.documentEntries.removeAll()
  
      let url = URL(string: "https://{URL}//CheckOut")!
      var request = URLRequest(url: url)
      request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") //Optional
      request.httpMethod = "POST"
      request.setValue("application/json", forHTTPHeaderField: "Content-Type")
      request.httpBody = jsonData
      let session = URLSession.shared
      let dataTask = session.dataTask(with: request)  { (data: Data?, response: URLResponse?, error: Error?) in
          if let resultat = response as! HTTPURLResponse?{
              if resultat.statusCode == 200{
                  if error != nil {
                  }
                  else {
                      print(data!)
      if let nydata = data{
          print("JSON String: \(String(data: data!, encoding: .utf8))")
                  }  
                  }
              }}
  }
  dataTask.resume()
  </code></pre>
  
  <p>}</p>