Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
Description
As proposed by matt.broadstone:
Similarly to JSONDecoder's dateDecodingStrategy, we should allow a user to choose how both Dates and UUIDs gets decoded.
The Date strategy should be pretty much identical to the JSONDecoder behavior there, though we may want to default to our current date decoding strategy instead of deferring to Date like JSONDecoder does by default.
We should provide an analogous option for UUIDs, so that we can support decoding them in the reverse manner of how this PR encodes them in UUID.encode(to storage....).
We already special case ambiguous errors involving Date decoding, and we should do the same for UUID too.
These options should be added via open properties on BSONDecoder that users can set, i.e. with something like:
let decoder = BSONDecoder()
|
decoder.dateDecodingStrategy = .deferredToDate
|
Therefore this will require implementing SWIFT-260.