KeyedDecodingContainer

struct KeyedDecodingContainer<K> : KeyedDecodingContainerProtocol where K : CodingKey
  • Decodes a value of the implicit type for the given key.

    Throws

    A DecodingError.

    Declaration

    Swift

    func decode<T>(forKey key: Key) throws -> T where T : Decodable

    Parameters

    key

    The key that the decoded value is associated with.

    Return Value

    A value of the implicitly requested type, if present for the given key and convertible to the implicitly requested type.

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

    Throws

    DecodingError.typeMismatch if the encountered encoded value is not convertible to the requested type.

    Declaration

    Swift

    func decodeIfPresent<T>(forKey key: Key) throws -> T? where T : Decodable

    Parameters

    key

    The key that the decoded value is associated with.

    Return Value

    A decoded value of the implicitly requested type, or nil if the Decoder does not have an entry associated with the given key, or if the value is a null value.