Post

Replies

Boosts

Views

Activity

Comment on Adding functionality to JSONDecoder (json decoding)
You can do something like that, but I need a more generic way, so I don't have to relay on if let, custom decoders, custom types, casting or similar. I have ended up using the extension mentioned above, which let me. class Jumps: Decodable { var value: Bool CodingKeys... required init(from decoder: Decoder) throws { let container = decoder.container... let value = try decodeWithUnknowType(Bool.self, for: .value) } } Not the most elegant, but usable and it cleans up a lot of my decoders.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21