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
Sendablevalues.Throws
EncodingErrorif any dictionary cannot be encodedDeclaration
Swift
public mutating func encode(contentsOf sequence: [[String : any Sendable]]) throwsParameters
sequenceThe array of dictionaries to encode
-
Encodes a dictionary with string keys and
Sendablevalues 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
EncodingErrorif any value cannot be encodedDeclaration
Swift
public mutating func encodeIfPresent(_ value: [String : any Sendable]) throwsParameters
valueThe dictionary to encode
View on GitHub