One of the main use cases for Codable
is to support integration of network (often JSON) APIs into client side apps with minimal code. Auto synthesis of Codable
conformances make it even easier to do so, by removing boilerplate.
Auto synthesis of structs, combined with JSONDecoder.keyDecodingStrategy
means we often need to write zero addition lines of code, apart from simply declaring members, and Swift simply does the right thing.
I realise that Codable
can also be used for many other things, and sometimes the underlying encoded bytes doesn't really matter, as long as encoding and decoding is idempotent up to Equality
.
However, when I do care about how types are encoded, is when they match existing APIs.
And I still haven't seen much evidence that the proposed encoding scheme is commonly used for one-of
types in real world APIs seen around the world. Can we please see more evidence of this? If the automatically synthesised comnformance, more often than not needs to be overridden, this proposal has little to no value.