Encodable

protocol Encodable
  • Directly encodes any Encodable object using any given encoder conforming to the AnyEncoder protocol.

    This generic instance method returns an encoded representation of a value adopting the Encodable protocol. The encoder used must conform to the AnyEncoder protocol but is of type JSONEncoder by default.

    Declaration

    Swift

    func encoded(using encoder: AnyEncoder = JSONEncoder()) throws -> Data

    Return Value

    An encoded object.