Question : swift read json from url
Answered by : upset-unicorn-62eall96mf2f
private func readLocalFile(forName name: String) -> Data? { do { if let bundlePath = Bundle.main.path(forResource: name, ofType: "json"), let jsonData = try String(contentsOfFile: bundlePath).data(using: .utf8) { return jsonData } } catch { print(error) } return nil
}
Source : https://programmingwithswift.com/parse-json-from-file-and-url-with-swift/ | Last Update : Tue, 19 Oct 21