UnkeyedDecodingContainer
extension UnkeyedDecodingContainer
Extensions for UnkeyedDecodingContainer to support decoding of dynamic arrays and dictionaries
with Sendable values from unkeyed JSON containers.
-
Decodes an array of
Sendablevalues from the current container.This method iterates through all elements in the unkeyed container and attempts to decode each as a Bool, Double, String, nested dictionary, or nested array. Null values are skipped.
Throws
DecodingErrorif the container cannot be processedDeclaration
Swift
public mutating func decode(_ type: [any Sendable].Type) throws -> [any Sendable]Parameters
typeThe type of array to decode
Return Value
An array of
Sendablevalues containing all successfully decoded elements -
Decodes a dictionary with string keys and
Sendablevalues from a nested container.Throws
DecodingErrorif the nested container cannot be decodedDeclaration
Swift
public mutating func decode(_ type: [String : any Sendable].Type) throws -> [String : any Sendable]Parameters
typeThe type of dictionary to decode
Return Value
A dictionary with string keys and
Sendablevalues
View on GitHub