Codable

Decoding Heterogenous JSON with Swift and Decodable

Yet another blog precipitated by a Stack Overflow post that niggled away at me. Decoding heterogenous JSON was something that I'd done in the past, but as always seems to be the case with complex JSON decoding, it took me a while to get my thinking clear and come up with a solution. This post details how to wrap the ambiguity of heterogenous data inside an enum with associated types for type-safe decoding with Swift and Codable.