KeyedDecodingContainer

A concrete container that provides a view into a decoder's storage, making the encoded properties of a decodable type accessible by keys.

Inheritance KeyedDecodingContainerProtocol
Associated Types
  • public typealias Key = K

Initializers

init init(_:) Required

Creates a new instance with the given container.

  • parameter container: The container to hold.

Declaration

Instance Variables

var allKeys Required

All the keys the decoder has for this container.

Different keyed containers from the same decoder may return different keys here, because it is possible to encode with multiple key types which are not convertible to one another. This should report all keys present which are convertible to the requested type.

Declaration

var codingPath Required

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

Declaration

Instance Methods

func contains(_ key: KeyedDecodingContainer<K>.Key) -> Bool Required

Returns a Boolean value indicating whether the decoder contains a value associated with the given key.

The value associated with the given key may be a null value as appropriate for the data format.

  • parameter key: The key to search for.

Declaration

func decode(_ type: Bool.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Bool Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: String.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> String Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Double.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Double Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Float.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Float Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Int.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Int8.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int8 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Int16.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int16 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Int32.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int32 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: Int64.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int64 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: UInt.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: UInt8.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt8 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: UInt16.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt16 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: UInt32.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt32 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: UInt64.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt64 Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decode(_ type: T.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> T Required

Decodes a value of the given type for the given key.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Bool.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Bool? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: String.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> String? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Double.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Double? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Float.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Float? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Int.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Int8.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int8? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Int16.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int16? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Int32.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int32? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Int64.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> Int64? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: UInt.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: UInt8.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt8? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: UInt16.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt16? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: UInt32.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt32? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: UInt64.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> UInt64? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: T.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> T? Required

Decodes a value of the given type for the given key, if present.

This method returns nil if the container does not have a value associated with key, or if the value is null. The difference between these states can be distinguished with a contains(_:) call.

  • parameter type: The type of value to decode.
  • parameter key: The key that the decoded value is associated with.

Declaration

func decodeIfPresent(_ type: Bool.Type, forKey key: Self.Key) throws -> Bool? Required

Declaration

  • public func decodeIfPresent(_ type: Bool.Type, forKey key: Self.Key) throws -> Bool?
func decodeIfPresent(_ type: String.Type, forKey key: Self.Key) throws -> String? Required

Declaration

  • public func decodeIfPresent(_ type: String.Type, forKey key: Self.Key) throws -> String?
func decodeIfPresent(_ type: Double.Type, forKey key: Self.Key) throws -> Double? Required

Declaration

  • public func decodeIfPresent(_ type: Double.Type, forKey key: Self.Key) throws -> Double?
func decodeIfPresent(_ type: Float.Type, forKey key: Self.Key) throws -> Float? Required

Declaration

  • public func decodeIfPresent(_ type: Float.Type, forKey key: Self.Key) throws -> Float?
func decodeIfPresent(_ type: Int.Type, forKey key: Self.Key) throws -> Int? Required

Declaration

  • public func decodeIfPresent(_ type: Int.Type, forKey key: Self.Key) throws -> Int?
func decodeIfPresent(_ type: Int8.Type, forKey key: Self.Key) throws -> Int8? Required

Declaration

  • public func decodeIfPresent(_ type: Int8.Type, forKey key: Self.Key) throws -> Int8?
func decodeIfPresent(_ type: Int16.Type, forKey key: Self.Key) throws -> Int16? Required

Declaration

  • public func decodeIfPresent(_ type: Int16.Type, forKey key: Self.Key) throws -> Int16?
func decodeIfPresent(_ type: Int32.Type, forKey key: Self.Key) throws -> Int32? Required

Declaration

  • public func decodeIfPresent(_ type: Int32.Type, forKey key: Self.Key) throws -> Int32?
func decodeIfPresent(_ type: Int64.Type, forKey key: Self.Key) throws -> Int64? Required

Declaration

  • public func decodeIfPresent(_ type: Int64.Type, forKey key: Self.Key) throws -> Int64?
func decodeIfPresent(_ type: UInt.Type, forKey key: Self.Key) throws -> UInt? Required

Declaration

  • public func decodeIfPresent(_ type: UInt.Type, forKey key: Self.Key) throws -> UInt?
func decodeIfPresent(_ type: UInt8.Type, forKey key: Self.Key) throws -> UInt8? Required

Declaration

  • public func decodeIfPresent(_ type: UInt8.Type, forKey key: Self.Key) throws -> UInt8?
func decodeIfPresent(_ type: UInt16.Type, forKey key: Self.Key) throws -> UInt16? Required

Declaration

  • public func decodeIfPresent(_ type: UInt16.Type, forKey key: Self.Key) throws -> UInt16?
func decodeIfPresent(_ type: UInt32.Type, forKey key: Self.Key) throws -> UInt32? Required

Declaration

  • public func decodeIfPresent(_ type: UInt32.Type, forKey key: Self.Key) throws -> UInt32?
func decodeIfPresent(_ type: UInt64.Type, forKey key: Self.Key) throws -> UInt64? Required

Declaration

  • public func decodeIfPresent(_ type: UInt64.Type, forKey key: Self.Key) throws -> UInt64?
func decodeIfPresent(_ type: T.Type, forKey key: Self.Key) throws -> T? Required

Declaration

  • public func decodeIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> T? where T: Decodable
func decodeNil(forKey key: KeyedDecodingContainer<K>.Key) throws -> Bool Required

Decodes a null value for the given key.

  • parameter key: The key that the decoded value is associated with.

Declaration

func nestedContainer(keyedBy type: NestedKey.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> KeyedDecodingContainer<NestedKey> Required

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

  • parameter type: The key type to use for the container.
  • parameter key: The key that the nested container is associated with.

Declaration

func nestedUnkeyedContainer(forKey key: KeyedDecodingContainer<K>.Key) throws -> UnkeyedDecodingContainer Required

Returns the data stored for the given key as represented in an unkeyed container.

  • parameter key: The key that the nested container is associated with.

Declaration

func superDecoder() throws -> Decoder Required

Returns a Decoder instance for decoding super from the container associated with the default super key.

Equivalent to calling superDecoder(forKey:) with Key(stringValue: "super", intValue: 0).

Declaration

  • public func superDecoder() throws -> Decoder
func superDecoder(forKey key: KeyedDecodingContainer<K>.Key) throws -> Decoder Required

Returns a Decoder instance for decoding super from the container associated with the given key.

  • parameter key: The key to decode super for.

Declaration