Decoding Swift types that require additional data
Swift by Sundell covers decoding Swift types that need data not present in the serialized input. The Codable API, combining Encodable and Decodable, lets types like a Movie struct be serialized automatically when the JSON matches their structure. A User type with a favorites property shows the problem of initializing values whose required data is missing from the JSON.
AI-written summary, checked against the cited sources. How summaries work