struct KeyedEncodingContainer<K> A concrete container that provides a view into an encoder's storage, making the encoded properties of an encodable type accessible by keys. Inheritance KeyedEncodingContainerProtocol View Protocol Hierarchy → Associated Types Key = K Import import Swift Initializers init(_:) Creates a new instance with the given container. container: The container to hold. Declaration init<Container>(_ container: Container) Instance Variables var codingPath: [CodingKey] The path of coding keys taken to get to this point in encoding. Declaration var codingPath: [CodingKey] { get } Instance Methods mutating func encode(_: Bool, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Bool, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Double, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Double, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Float, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Float, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Int, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Int, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Int8, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Int8, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Int16, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Int16, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Int32, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Int32, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: Int64, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: Int64, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: String, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: String, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: UInt, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: UInt, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: UInt8, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: UInt8, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: UInt16, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: UInt16, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: UInt32, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: UInt32, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode(_: UInt64, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode(_ value: UInt64, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encode<T>(_: T, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encode<T>(_ value: T, forKey key: KeyedEncodingContainer<K>.Key) throws mutating func encodeConditional(_:forKey:) Encodes a reference to the given object only if it is encoded unconditionally elsewhere in the payload (previously, or in the future). For encoders which don't support this feature, the default implementation encodes the given object unconditionally. object: The object to encode. key: The key to associate the object with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeConditional<T>(_ object: T, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Bool?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Bool?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Double?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Double?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Float?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Float?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Int?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Int?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Int8?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Int8?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Int16?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Int16?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Int32?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Int32?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: Int64?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: Int64?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: String?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: String?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: UInt?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: UInt?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: UInt8?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: UInt8?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: UInt16?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: UInt16?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: UInt32?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: UInt32?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent(_: UInt64?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent(_ value: UInt64?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeIfPresent<T>(_: T?, forKey: KeyedEncodingContainer<K>.Key) Encodes the given value for the given key if it is not nil. value: The value to encode. key: The key to associate the value with. throws: EncodingError.invalidValue if the given value is invalid in the current context for this format. Declaration mutating func encodeIfPresent<T>(_ value: T?, forKey key: KeyedEncodingContainer<K>.Key) throws Declared In KeyedEncodingContainer, KeyedEncodingContainerProtocol mutating func encodeNil(forKey:) Encodes a null value for the given key. key: The key to associate the value with. throws: EncodingError.invalidValue if a null value is invalid in the current context for this format. Declaration mutating func encodeNil(forKey key: KeyedEncodingContainer<K>.Key) throws mutating func nestedContainer(keyedBy:forKey:) Stores a keyed encoding container for the given key and returns it. keyType: The key type to use for the container. key: The key to encode the container for. returns: A new keyed encoding container. Declaration mutating func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type, forKey key: KeyedEncodingContainer<K>.Key) -> KeyedEncodingContainer<NestedKey> where NestedKey : CodingKey mutating func nestedUnkeyedContainer(forKey:) Stores an unkeyed encoding container for the given key and returns it. key: The key to encode the container for. returns: A new unkeyed encoding container. Declaration mutating func nestedUnkeyedContainer(forKey key: KeyedEncodingContainer<K>.Key) -> UnkeyedEncodingContainer mutating func superEncoder() Stores a new nested container for the default super key and returns A new encoder instance for encoding super into that container. Equivalent to calling superEncoder(forKey:) with Key(stringValue: "super", intValue: 0). returns: A new encoder to pass to super.encode(to:). Declaration mutating func superEncoder() -> Encoder mutating func superEncoder(forKey:) Stores a new nested container for the given key and returns A new encoder instance for encoding super into that container. key: The key to encode super for. returns: A new encoder to pass to super.encode(to:). Declaration mutating func superEncoder(forKey key: KeyedEncodingContainer<K>.Key) -> Encoder