I have an EmailVerificationStatus
enum with an associated type of String
that conforms to the Codable
protocol:
enum EmailVerificationStatus: String, Codable {
case unverified
case verified
}
The webservice I am working with sends those cases in uppercase (UNVERIFIED
/ VERIFIED
). How can I use the CodingKeys
enumeration to map that difference? Something like the following does not work:
enum CodingKeys: String, CodingKey {
case unverified = "UNVERIFIED"
case verified = "VERIFIED"
}
Codable
s since they were introduced, but ran into this problem, too, and I can't believe I didn't think of this. I've been beating my head on the wall for a couple hours. – Amara