KeyedEncodingContainer
extension KeyedEncodingContainer
-
Encodes the given value for the given key.
Throws
EncodingError.invalidValue
if the given value is invalid in the current context for this format.Declaration
Swift
public mutating func encode(_ value: [String : Any], forKey key: KeyedEncodingContainer<K>.Key) throws
Parameters
value
The value to encode.
key
The key to associate the value with.
-
Encodes the given value for the given key.
Throws
EncodingError.invalidValue
if the given value is invalid in the current context for this format.Declaration
Swift
public mutating func encode(_ value: [Any], forKey key: KeyedEncodingContainer<K>.Key) throws
Parameters
value
The value to encode.
key
The key to associate the value with.
-
Encodes the given value for the given key if it is not
nil
.Throws
EncodingError.invalidValue
if the given value is invalid in the current context for this format.Declaration
Swift
public mutating func encodeIfPresent(_ value: [String : Any]?, forKey key: KeyedEncodingContainer<K>.Key) throws
Parameters
value
The value to encode.
key
The key to associate the value with.
-
Encodes the given value for the given key if it is not
nil
.Throws
EncodingError.invalidValue
if the given value is invalid in the current context for this format.Declaration
Swift
public mutating func encodeIfPresent(_ value: [Any]?, forKey key: KeyedEncodingContainer<K>.Key) throws
Parameters
value
The value to encode.
key
The key to associate the value with.