Skip to content

Case

JSONEncoder.DataEncodingStrategy.custom(_:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
The strategy that encodes data using a user-defined function.
@preconcurrency case custom(@Sendable (Data, any Encoder) throws -> Void)

Discussion

If the closure fails to encode a value into the given encoder, the encoder will encode an empty automatic container in its place.