UnkeyedEncodingContainer

extension UnkeyedEncodingContainer

Extensions for UnkeyedEncodingContainer to support encoding of arrays of dictionaries with Sendable values into unkeyed JSON containers.

  • Encodes an array of dictionaries with string keys and Sendable values.

    Throws

    EncodingError if any dictionary cannot be encoded

    Declaration

    Swift

    public mutating func encode(contentsOf sequence: [[String : any Sendable]]) throws

    Parameters

    sequence

    The array of dictionaries to encode

  • Encodes a dictionary with string keys and Sendable values into a nested container.

    This method creates a nested keyed container and encodes each value based on its runtime type, supporting Int, String, Double, Float, Bool, arrays, and nested dictionaries.

    Throws

    EncodingError if any value cannot be encoded

    Declaration

    Swift

    public mutating func encodeIfPresent(_ value: [String : any Sendable]) throws

    Parameters

    value

    The dictionary to encode