How to work with Alamofire Sponse on Swift 4?

Asked

Viewed 442 times

1

I have the following request that returns me a json I cannot catch the live ulrs

Alamofire.request(urlRequest).validate().responseJSON { response in
                print(response.data)

                do {
                    if let data = response.data,
                        let json = try JSONSerialization.jsonObject(with: data) as? [String: Any],
                        let live = json["live"] as? [[String: Any]] {
                        for live in live {
                            if let livesUrl = live["live"] as? String {
                                self.urlLive.append(liveUrl)
                            }
                        }
                    }

                } catch {
                    print("Error deserializing JSON: \(error)")
                }
                print(self.urlLive)
            }

JSON REQUEST ME RETURNS

[ { "id": "1", "Description": "TEST 1", "live": "https://....", "Thumb": "https://....", "online": true }, { "id": "2", "Description": "TEST 2", "live": "https://....", "Thumb": "https://....", "online": true }]

  • Pq Voce does not use Codable Protocol instead of manually parsing your JSON?

  • has an example of how to use?

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.