Open utterances-bot opened 3 years ago
Great article. One thing that may improve and generalize conditional decoding is to introduce enum that conforms to Decodable where each case is generic. This approach is described here.
Going further, you can use this enum inside init(from decoder:)
. Also you can introduce computed properties on the enum to provide value of the type you need by doing desired conversion under the hood.
Parsing Tricky JSON With Codable in Swift • Andy Ibanez
https://www.andyibanez.com/posts/parsing-tricky-json-codable-swift/