KeyPathEncoding

public struct KeyPathEncoding : Sendable

Encoding to use for nested object and Encodable value key paths.

["parent" : ["child" : ["grandchild": "value"]]]

This encoding affects how the parent, child, grandchild path is encoded. Brackets are used by default. e.g. parent[child][grandchild]=value.

  • Encodes key paths by wrapping each component in brackets. e.g. parent[child][grandchild].

    Declaration

    Swift

    public static let brackets: URLEncodedFormEncoder.KeyPathEncoding
  • Encodes key paths by separating each component with dots. e.g. parent.child.grandchild.

    Declaration

    Swift

    public static let dots: URLEncodedFormEncoder.KeyPathEncoding
  • Creates an instance with the encoding closure called for each sub-key in a key path.

    Declaration

    Swift

    public init(encoding: @escaping @Sendable (_ subkey: String) -> String)

    Parameters

    encoding

    Closure used to perform the encoding.