I'd like to be able to set the keyDecodingStrategy of the default JSONDecoder to .convertFromSnakeCase, but that doesn't seem possible at the moment?
So instead I now have to give the CodingKeys by hand.
struct Upload: Codable {
let id: Int
let user: User
let mediaType: String
let image: String
let thumbnail: String
let description: String
enum CodingKeys: String, CodingKey {
case id
case user
case mediaType = "media_type"
case image
case thumbnail
case description
}
}
This is a little bit annoying considering all of that could be automated away with setting the keyDecodingStrategy :)
This could be done the same way that the date encoding strategy can already be customized.
I'd like to be able to set the
keyDecodingStrategyof the default JSONDecoder to.convertFromSnakeCase, but that doesn't seem possible at the moment?So instead I now have to give the
CodingKeysby hand.This is a little bit annoying considering all of that could be automated away with setting the
keyDecodingStrategy:)This could be done the same way that the date encoding strategy can already be customized.