KeyedDecodingContainer
public extension KeyedDecodingContainer
-
Decodes a value of the given type for the given key if present and if not, returns the provided default value.
Throws
AnErrorif the decoding process encounters an error.Declaration
Swift
func decode<T>(forKey key: K, defaultValue: T) throws -> T where T: DecodableParameters
keyThe key that the decoded value is associated with.
defaultValueThe value to use if the key decoded is not present.
Return Value
A decoded value of the requested type, or the default value if the Decoder does not have an entry associated with the given key, or if the value is a null value.
KeyedDecodingContainer Extension Reference