<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I’m still not convinced that we should actually provide such a strategy.<div class=""><br class=""></div><div class="">Conversions like those below seem like the domain of each type that is being decoded. If, in a particular type, the “number” can be either a true number or a string, then that type can try decoding it as one or the other and fall back as required. That puts the responsibility of doing that kind of conversion in the type itself.</div><div class=""><br class=""></div><div class="">JSON has very few types already. I’m not sure we want to blur the line between numbers and strings automatically…</div><div class=""><br class=""></div><div class="">- Tony<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 30, 2017, at 11:24 AM, Sneed, Brandon via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class="">Hi Itai,<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class="">No problem!&nbsp; Thanks for the heads up.&nbsp; Is there any way I could be involved?&nbsp; Happy to do the work to whatever guidance your team might have.&nbsp; I’m mostly just interested in it being there soon, hence volunteering.<span class="Apple-converted-space">&nbsp;</span><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class="">Thanks!<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class="">Brandon Sneed<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri;" class=""><o:p class="">&nbsp;</o:p></span></div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><b class=""><span style="font-family: Calibri;" class="">From:<span class="Apple-converted-space">&nbsp;</span></span></b><span style="font-family: Calibri;" class="">&lt;<a href="mailto:iferber@apple.com" class="">iferber@apple.com</a>&gt; on behalf of Itai Ferber &lt;<a href="mailto:iferber@apple.com" class="">iferber@apple.com</a>&gt;<br class=""><b class="">Date:<span class="Apple-converted-space">&nbsp;</span></b>Wednesday, August 30, 2017 at 11:22 AM<br class=""><b class="">To:<span class="Apple-converted-space">&nbsp;</span></b>"Sneed, Brandon" &lt;<a href="mailto:brsneed@ebay.com" class="">brsneed@ebay.com</a>&gt;<br class=""><b class="">Cc:<span class="Apple-converted-space">&nbsp;</span></b>"<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>" &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt;<br class=""><b class="">Subject:<span class="Apple-converted-space">&nbsp;</span></b>Re: [swift-corelibs-dev] Adding type conversion capabilities to JSON encode/decode<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><o:p class="">&nbsp;</o:p></div></div><div class=""><div class=""><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-family: Helvetica;" class="">Hi Brandon,<o:p class=""></o:p></span></p><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-family: Helvetica;" class="">Thanks for looking at this! We’ve got plans internally to potentially add a strategy to<span class="Apple-converted-space">&nbsp;</span></span><code style="font-family: &quot;Courier New&quot;;" class=""><span style="font-size: 10pt; background-color: rgb(247, 247, 247); background-position: initial initial; background-repeat: initial initial;" class="">JSONEncoder</span></code><span style="font-family: Helvetica;" class="">/</span><code style="font-family: &quot;Courier New&quot;;" class=""><span style="font-size: 10pt; background-color: rgb(247, 247, 247); background-position: initial initial; background-repeat: initial initial;" class="">JSONDecoder</span></code><span style="font-family: Helvetica;" class=""><span class="Apple-converted-space">&nbsp;</span>to allow lenient conversions like this — i.e. implicitly stringify numbers (or parse them from string input), among some others.<br class="">This would be opt-in for consumers of<span class="Apple-converted-space">&nbsp;</span></span><code style="font-family: &quot;Courier New&quot;;" class=""><span style="font-size: 10pt; background-color: rgb(247, 247, 247); background-position: initial initial; background-repeat: initial initial;" class="">JSONDecoder</span></code><span style="font-family: Helvetica;" class=""><span class="Apple-converted-space">&nbsp;</span>while not requiring any special annotations on<span class="Apple-converted-space">&nbsp;</span></span><code style="font-family: &quot;Courier New&quot;;" class=""><span style="font-size: 10pt; background-color: rgb(247, 247, 247); background-position: initial initial; background-repeat: initial initial;" class="">Codable</span></code><span style="font-family: Helvetica;" class=""><span class="Apple-converted-space">&nbsp;</span>types.<o:p class=""></o:p></span></p><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-family: Helvetica;" class="">— Itai<o:p class=""></o:p></span></p><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-family: Helvetica;" class="">On 30 Aug 2017, at 10:59, Sneed, Brandon via swift-corelibs-dev wrote:<o:p class=""></o:p></span></p></div><blockquote style="border-style: none none none solid; border-left-width: 1.5pt; border-left-color: rgb(119, 119, 119); padding: 0in 0in 0in 4pt; margin-left: 0in; margin-right: 0in; margin-bottom: 3.75pt;" class=""><div id="51AAF58D-1B44-4118-93E0-827F3EEB8D2A" class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Hi everyone,</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Just throwing this out to see if anyone else is working on this, or has opinions/suggestions on how it’s implemented.&nbsp; I’d like to add this to the Codable/JSONDecoder/JSONEncoder system if no one else is working on it.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Type type conversion, I mean given this JSON payload:</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">{</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; &nbsp; &nbsp; "name": "Endeavor”,</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; &nbsp; &nbsp; "abv": 8.9,</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; &nbsp; &nbsp; "brewery": "Saint Arnold”,</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; &nbsp; &nbsp; "style": "ipa"</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">}</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">and a struct defined as:</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">struct Beer: Codable {</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let name: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let abv: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let brewery: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let style: BeerStyle</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">}</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Notice that “abv” is a number in the JSON, but a String in the struct.&nbsp; I’d like to make it such that I can let the system know it’s ok to convert it from a number to a string as opposed to throwing an exception.&nbsp; The benefits are:</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It’s defensive; service types can change without causing my application to crash.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It allows a developer to work with the types they want to work with as opposed to what the server provides, thus saving them time of writing a custom encode/decode code for all members.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">The argument against it that I’ve heard is generally “it’s a service bug, make them fix it”, which is valid but the reality is we’re not all in control of the services we injest.&nbsp; The same type of logic could be applied to a member name changing, though I haven’t seen this happen often in practice.&nbsp; I do see types in a json payload change with some frequency though.&nbsp; I think much of the reason stems from the fact that type conversion in javascript is effectively free, ie: you ask for a String, you get a String if possible.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">To implement this type conversion in practice, looking at it from the point of view using Codable/JSON(en/de)coder, one way would be to make it opt-in:</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">struct Beer: Codable, CodingConvertible {</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let name: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let abv: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let brewery: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let style: BeerStyle</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">}</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">I like this because looking at the struct, the members still remain clear and relatively unambiguous.&nbsp; The downside is it’s unknown which member is likely to get converted.&nbsp; And since it’s opt-in, conversion doesn’t happen if the CodingConvertible conformance isn’t adhered to.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Another option would be to box each type, like so:</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">struct Beer: Codable {</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let name: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let abv: Convertible&lt;String&gt;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let brewery: String</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp; &nbsp; let style: BeerStyle</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">}</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">This seems tedious for developers, but would show which types are being converted.&nbsp; It does however seriously weaken benefit #1 above.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Those example usages above aside, I do think it’d be best if this conversion behavior was the default and no end-developer changes required.&nbsp; I think that could be done without impact to code that’s been already been written against the JSON en/decode bits.</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">I’m very open to alternatives, other ideas, or anything else you might have to say on the subject.&nbsp; Thanks for reading!</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">Brandon Sneed</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-size: 11pt; font-family: Calibri; color: rgb(119, 119, 119);" class="">&nbsp;</span><span style="font-family: Calibri; color: rgb(119, 119, 119);" class=""><o:p class=""></o:p></span></div></div></div></blockquote><div class=""><blockquote style="border-style: none none none solid; border-left-width: 1.5pt; border-left-color: rgb(119, 119, 119); padding: 0in 0in 0in 4pt; margin-left: 0in; margin-right: 0in; margin-bottom: 3.75pt;" class=""><p style="margin-right: 0in; margin-left: 0in; font-size: 12pt; font-family: &quot;Times New Roman&quot;;" class=""><span style="font-family: Helvetica; color: rgb(119, 119, 119);" class="">_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.swift.org%2Fmailman%2Flistinfo%2Fswift-corelibs-dev&amp;data=02%7C01%7Cbrsneed%40ebay.com%7C0e58a975be44418826d608d4efd427dc%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C636397141865218008&amp;sdata=ytYIqDtMesw4NnpUbFmiWF2%2FKfxlawG4YuVWPJd099Y%3D&amp;reserved=0" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(119, 119, 119);" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</span></a><o:p class=""></o:p></span></p></blockquote></div></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">swift-corelibs-dev mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""></div></blockquote></div><br class=""></div></body></html>