On the top of my head, we sometimes need to customize the decoding of "blank values", for example:
-
Decoding a non-optional
String
in such a way thatnull
,absent
are decoded as""
.
This happens when the app wants to encode the lack of information as""
. -
Decoding a
String?
in such a way thatnull
,absent
,""
, maybe even strings only made of white spaces, are decoded asnil
.
This happens when the app wants to encode the lack of information asnil
.
Some for Int
, Double
, etc. where 0
could take place of ""
.
All of that was customizable and possible with Decodable
(often verbose, maybe with the help of a dedicated value type, but possible).
I wish it were possible for apps to provide custom decoding strategies without the need to write a macro.