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 Sendable values 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

    DecodingError if the container cannot be processed

    Declaration

    Swift

    public mutating func decode(_ type: [any Sendable].Type) throws -> [any Sendable]

    Parameters

    type

    The type of array to decode

    Return Value

    An array of Sendable values containing all successfully decoded elements

  • Decodes a dictionary with string keys and Sendable values from a nested container.

    Throws

    DecodingError if the nested container cannot be decoded

    Declaration

    Swift

    public mutating func decode(_ type: [String : any Sendable].Type) throws -> [String : any Sendable]

    Parameters

    type

    The type of dictionary to decode

    Return Value

    A dictionary with string keys and Sendable values