Swift 4\'s new Encodable/Decodable protocols make JSON (de)serialization quite pleasant. However, I have not yet found a way to have fine-grained c
Encodable
Decodable
You can use computed properties:
struct Person: Codable { var firstName: String var lastName: String var nickname: String? var nick: String { get { nickname ?? "" } } private enum CodingKeys: String, CodingKey { case firstName, lastName } }