URLEncodedFormEncoder_KeyEncoding - SwiftDocOrg/Alamofire GitHub Wiki
URLEncodedFormEncoder.KeyEncoding
Encoding to use for keys.
public enum KeyEncoding
This type is derived from JSONEncoder's KeyEncodingStrategy
and XMLEncoders KeyEncodingStrategy.
Enumeration Cases
useDefaultKeys
Use the keys specified by each type. This is the default encoding.
case useDefaultKeys
convertToSnakeCase
Convert from "camelCaseKeys" to "snake_case_keys" before writing a key.
case convertToSnakeCase
Capital characters are determined by testing membership in
CharacterSet.uppercaseLetters and CharacterSet.lowercaseLetters
(Unicode General Categories Lu and Lt).
The conversion to lower case uses Locale.system, also known as
the ICU "root" locale. This means the result is consistent
regardless of the current user's locale and language preferences.
Converting from camel case to snake case:
- Splits words at the boundary of lower-case to upper-case
- Inserts
_between words - Lowercases the entire string
- Preserves starting and ending
_.
For example, oneTwoThree becomes one_two_three. _oneTwoThree_ becomes _one_two_three_.
convertToKebabCase
Same as convertToSnakeCase, but using - instead of _.
For example oneTwoThree becomes one-two-three.
case convertToKebabCase
capitalized
Capitalize the first letter only.
For example oneTwoThree becomes OneTwoThree.
case capitalized
uppercased
Uppercase all letters.
For example oneTwoThree becomes ONETWOTHREE.
case uppercased
lowercased
Lowercase all letters.
For example oneTwoThree becomes onetwothree.
case lowercased
custom
A custom encoding using the provided closure.
case custom(: (String) -> String)