I'm trying to decode data from this massive JSON Array https://************** /countries I've had luck decoding by country or using the total stat worldwide https://********* by doing the following
[PLEASE DELETE SOLVED OUT OF SWIFT FORUMS]
I'm trying to decode data from this massive JSON Array https://************** /countries I've had luck decoding by country or using the total stat worldwide https://********* by doing the following
[PLEASE DELETE SOLVED OUT OF SWIFT FORUMS]
Probably you first want to update your JSONTest struct to include the country:
struct JSONTest: Decodable {
let country: String
let cases: Double
let deaths: Float
let recovered: Int?
}
The JSON for all the countries is an array of JSONTest objects, therefore you need to decode it as such:
let countries = try JSONDecoder().decode([JSONTest].self, from: data)
You can then use the countries array to update your UI.
Thanks but I want for all countries not just one, I solved it by making one class for every country , about 190 classes and 190 uiview controllers xD I know this is dumb but the reason is that I'm new to programing in general