Why is it the error occurring only for "codechefRoot" while other struct objects work just fine?
I mean codechefRoot is as same as other struct objects, why the error occurring only at it.
import Foundation
struct codeforcesRoot: Decodable {
var status: String
var result: [codeforcesData]
}
struct codeforcesData: Decodable {
var handle: String
var rank: String
var rating: Int
}
struct interviewbitRoot: Decodable {
var rank: String
var score: String
var streak: String
}
struct codechefRoot: Decodable {
var rank: String
var global_rank: String
var country_rank: String
var contest: [contestsData]
}
struct contestsData {
var name: String
var rating: String
var global_rank: String
var country_rank: String
}
You get this error because your contestsData
type does not conform to Decodable
.
By changing struct contestsData {..}
to struct contestsData: Decodable {..}
should fix it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.