Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- First step:
- struct Response: Codable {
- let dates: [String: CustomDate]
- let metadata: Metadata
- let total: Total
- let updated_at: String //Should be a date, but that adds another complexity
- }
- struct CustomDate: Codable {
- let countries: [String: Country]
- let info: Infos
- }
- struct Infos: Codable {
- let date: String
- let date_generation: String
- let yesterday: String
- }
- struct Country: Codable {
- let date: String
- let name: String
- }
- struct Metadata: Codable {
- let by: String
- let url: [String]
- }
- struct Total: Codable {
- let name: String
- }
- I skipped a few things, but it works then with:
- let foundDate = values.dates["2020-11-04"]?.countries["Afghanistan"]?.date
- print(foundDate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement