JSONEncoder.DateEncodingStrategy.custom(_:)
The strategy that formats custom dates by calling a user-defined function.
Declaration
@preconcurrency case custom(@Sendable (Date, any Encoder) throws -> Void)Parameters
- custom:
A closure that receives the data to encode and the encoder instance to encode to.
Discussion
If the user-defined function throws, the error propagates upward.
If the user-defined function doesn’t perform any encoding at all, the encoder produces an empty JSON object instead.