Decoder

protocol Decoder

A type that can decode values from a native format into in-memory representations.

Import import Swift

Instance Variables

var codingPath: [CodingKey] Required

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

Declaration

var codingPath: [CodingKey] { get }
var userInfo: [CodingUserInfoKey : Any] Required

Any contextual information set by the user for decoding.

Declaration

var userInfo: [CodingUserInfoKey : Any] { get }

Instance Methods

func container(keyedBy:) Required

Returns the data stored in this decoder as represented in a container keyed by the given key type.

type: The key type to use for the container. returns: A keyed decoding container view into this decoder. throws: DecodingError.typeMismatch if the encountered stored value is not a keyed container.

Declaration

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

Returns the data stored in this decoder as represented in a container appropriate for holding a single primitive value.

returns: A single value container view into this decoder. throws: DecodingError.typeMismatch if the encountered stored value is not a single value container.

Declaration

func singleValueContainer() throws -> SingleValueDecodingContainer
func unkeyedContainer() Required

Returns the data stored in this decoder as represented in a container appropriate for holding values with no keys.

returns: An unkeyed container view into this decoder. throws: DecodingError.typeMismatch if the encountered stored value is not an unkeyed container.

Declaration

func unkeyedContainer() throws -> UnkeyedDecodingContainer