Back to Alamofire

KeyPathEncoding

docs/Classes/URLEncodedFormEncoder/KeyPathEncoding.html

5.12.01.2 KB
Original Source

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.

`

                brackets
                `

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

Declaration

Swift

public static let brackets: URLEncodedFormEncoder.KeyPathEncoding

`

                dots
                `

Encodes key paths by separating each component with dots. e.g. parent.child.grandchild.

Declaration

Swift

public static let dots: URLEncodedFormEncoder.KeyPathEncoding

`

                init(encoding:)
                `

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.

|