KeyedDecodingContainer
public extension KeyedDecodingContainer
KeyedDecodingContainer+Decodable adds the ability to decode an array
Version
1.6.0Date
30/03/2019-
Decode an array if presented
Throws
DecodingError.typeMismatchif the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.Throws
DecodingError.valueNotFoundif the encountered encoded value is null, or of there are no more values to decode.Declaration
Swift
func decodeArrayIfPresent<O>(for key: K) throws -> [O]? where O : DecodableParameters
keyThe coding key
Return Value
An array of objects
-
Decode an array
Throws
DecodingError.typeMismatchif the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.Throws
DecodingError.valueNotFoundif the encountered encoded value is null, or of there are no more values to decode.Declaration
Swift
func decodeArray<O>(for key: K) throws -> [O] where O : DecodableParameters
keyThe coding key
Return Value
An array of objects
-
Decode an optional value or object
Throws
DecodingError.typeMismatchif the encountered encoded value is not convertible to the requested type.Declaration
Swift
func decodeIfPresent<O>(for key: K) throws -> O? where O : DecodableParameters
keyThe coding key
Return Value
The value or object
-
Decode a value or object
Throws
DecodingError.typeMismatchif the encountered encoded value is not convertible to the requested type.Declaration
Swift
func decode<O>(for key: K) throws -> O where O : DecodableParameters
keyThe coding key
Return Value
The value or object
KeyedDecodingContainer Extension Reference