Answers for "get json from url swift"

0

swiftUI parse json from url

struct Response: Codable {
    var results: [Result]
}

struct Result: Codable {
    var trackId: Int
    var trackName: String
    var collectionName: String
}
Posted by: Guest on February-21-2021
0

swift read json from url

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
}
Posted by: Guest on October-12-2021

Code answers related to "Swift"

Browse Popular Code Answers by Language