Contents

JSONEncoder.DataEncodingStrategy.custom(_:)

The strategy that encodes data using a user-defined function.

Declaration

@preconcurrency case custom(@Sendable (Data, 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 encoder uses an empty container in place of the data.