Is it possible to convert this code so as to get JSON from the URL and not just from the file that is in the application
let urlRequest = URLRequest(url: URL(string: "")!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 10) let dataTask = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) -> Void in do{ guard error == nil, let responseData = data, let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: .mutableContainers) as? [String: Any] else { return } //handle object //print(jsonObject) if let postsArray = jsonObject?["data"] as? [[String: AnyObject]] { self.posts = [Post]() for postDictionary in postsArray { let post = Post() post.setValuesForKeys(postDictionary) self.posts.append(post) print("\(post.image2)") } } }catch let err { print(err) } } dataTask.resume() If so, please tell me how, but I myself cannot catch up with something. Thank you in advance.