Encoder

protocol Encoder

A type that can encode values into a native format for external representation.

Instance Variables

var codingPath Required

The path of coding keys taken to get to this point in encoding.

Declaration

var codingPath: [CodingKey]
var userInfo Required

Any contextual information set by the user for encoding.

Declaration

var userInfo: [CodingUserInfoKey : Any]

Instance Methods

func container(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> Required

Returns an encoding container appropriate for holding multiple values keyed by the given key type.

You must use only one kind of top-level encoding container. This method must not be called after a call to unkeyedContainer() or after encoding a value through a call to singleValueContainer()

  • parameter type: The key type to use for the container.

Declaration

func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key: CodingKey
func singleValueContainer() -> SingleValueEncodingContainer Required

Returns an encoding container appropriate for holding a single primitive value.

You must use only one kind of top-level encoding container. This method must not be called after a call to unkeyedContainer() or container(keyedBy:), or after encoding a value through a call to singleValueContainer()

Declaration

func singleValueContainer() -> SingleValueEncodingContainer
func unkeyedContainer() -> UnkeyedEncodingContainer Required

Returns an encoding container appropriate for holding multiple unkeyed values.

You must use only one kind of top-level encoding container. This method must not be called after a call to container(keyedBy:) or after encoding a value through a call to singleValueContainer()

Declaration

func unkeyedContainer() -> UnkeyedEncodingContainer