You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
kevinrenskers
changed the title
Customize the decoder with a
Customize the decoder with a keyDecodingStrategy
Apr 5, 2019
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.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.
The text was updated successfully, but these errors were encountered: