<div dir="ltr"><div>Forgive me if I&#39;m missing something, this is a very large proposal and a lot to parse through. I like how everything is designed as far as I can tell except I&#39;m not sure from this proposal how one would compose multiple different types of Decoders against the same output type. For example, with Location we have.</div><div><br></div><div>// Continuing examples from before; below is automatically generated by the compiler if no customization is needed.</div><div>public struct Location : Codable {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>private enum CodingKeys : CodingKey {</div><div>        case latitude</div><div>        case longitude</div><div>    }</div><div><br></div><div>    public init(from decoder: Decoder) throws {</div><div>        let container = try decoder.container(keyedBy: CodingKeys.self)</div><div>        latitude = try container.decode(Double.self, forKey: .latitude)</div><div>        longitude = try container.decode(Double.self, forKey: .longitude)</div><div>    }</div><div>}</div><div><br></div><div>However, this initializer seems strictly tied to the `CodingKeys` set of coding keys. From what it appears, if this was used to decode from JSON the format would have to always be:</div><div><br></div><div>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&quot;latitude&quot; : 20.0</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&quot;longitude&quot; : 20.0</div><div>}</div><div><br></div><div>I have a use case we&#39;re on my client we began the process of switching from one version of an API to another. In one version we had a payload similar to</div><div><br></div><div>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>&quot;user&quot; : {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>&quot;uuid&quot; : &quot;uuid string...&quot;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>&quot;can_send_message&quot; : true</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>&quot;can_delete_message&quot; : false</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div>this would result in the following Codable (from &quot;user&quot;) from what I&#39;m following</div><div><br></div><div>public struct User : Codable {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>private enum CodingKeys : CodingKey {</div><div>        case uuid</div><div>        case can_send_message</div><div>        case can_delete_message</div><div>    }</div><div><br></div><div>    public init(from decoder: Decoder) throws {</div><div>        let container = try decoder.container(keyedBy: CodingKeys.self)</div><div>        uuid = try container.decode(Double.self, forKey: .uuid)</div><div>        canSendMessage = try container.decode(Bool.self, forKey: .can_send_message)</div><div>        canDeleteMessage = try container.decode(Bool.self, forKey: .can_delete_message)</div><div>    }</div><div>}</div><div><br></div><div>when we began switching over to the new api the payload was returned as</div><div><br></div><div>{</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>user {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>&quot;uuid&quot; : &quot;uuid string...&quot;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>&quot;permissions&quot; : {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>&quot;can_send_message&quot; : true</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>&quot;can_delete_message&quot; : false</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div>Here with &quot;permissions&quot; we have a new internal container with a separate set of coding keys. Issue is in my use case I still need to maintain a way to decode the old version simultaneously; we guard all new changes behind feature flags in case something goes awry and we need to roll back our changes.</div><div><br></div><div>How would one go about expressing this new Decoding and the previous Decoding simultaneously on the same User type?</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:arial;background-color:transparent;font-style:italic;vertical-align:baseline;white-space:pre-wrap">Rex Fenley</span><span style="font-size:16px;font-family:arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">|</span><span style="line-height:1.15;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">  </span><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">IOS DEVELOPER</span><br></p></span><span><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11px;font-family:arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh5.googleusercontent.com/xMgzw3JkFL3DLkdwyq0WxJzKs_XP57gVVCaBMvgi1FKCjSeue0xdx3JZeCWBlxN4KRHhHOfdvJbc1N-AjTwXcKIq4cjJg9H7iaFpQ8WbO4N3c9Y5dzi19cPOs_owPquuqw" width="250px;" height="53px;" style="border: none;"></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="https://www.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);font-weight:bold;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Remind.com</span></a><span style="font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">|  </span><a href="http://blog.remind.com/" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">BLOG</span></a><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  |  </span><a href="https://twitter.com/remindhq" style="text-decoration:none" target="_blank"><span style="font-size:11px;font-family:arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">FOLLOW US</span></a><span style="font-size:11px;font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">  | </span><span style="font-family:arial;vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> </span><span style="text-decoration:underline;font-size:11px;font-family:arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="https://www.facebook.com/remindhq" style="text-decoration:none" target="_blank">LIKE US</a></span></p></span></div></div>
</div>