marksands.github.io - Mark Sands

Description: Programming Tidbits

Example domain paragraphs

About Better Codable Through Property Wrappers October 21, 2019

With the introduction of Codable in Swift 4, working with JSON has never been more pleasant. Until it’s not. Codable definitely has its warts, and often the pain is introduced by suffering through boilerplate of implementing custom Decodable initializers.

Fortunately, Swift 5.1 introduced a feature known as property wrappers that can take all of that boilerplate away. While it doesn’t magically solve every painpoint with Codable, it definitely makes working with it much more pleasant. To that end, I’ve been accumulating my own wrappers on my GitHub at github.com/marksands/BetterCodable . Keep reading for a deep dive into their implementation and what it has to offer.