SmartKeyDecodingStrategy
public enum SmartKeyDecodingStrategy : Sendable
Undocumented
-
Use the keys specified by each type. This is the default strategy.
Declaration
Swift
case useDefaultKeys
-
Convert from “snake_case_keys” to “camelCaseKeys” before attempting to match a key with the one specified by each type.
The conversion to upper 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 snake case to camel case:
- Capitalizes the word starting after each
_
- Removes all
_
- Preserves starting and ending
_
(as these are often used to indicate private variables or other metadata). For example,one_two_three
becomesoneTwoThree
._one_two_three_
becomes_oneTwoThree_
.
Note
Using a key decoding strategy has a nominal performance cost, as each string key has to be inspected for the_
character.Declaration
Swift
case fromSnakeCase
- Capitalizes the word starting after each
-
Convert the first letter of the key to lower case before attempting to match a key with the one specified by each type. For example,
OneTwoThree
becomesoneTwoThree
.Note
This strategy should be used with caution, especially if the key’s first letter is intended to be uppercase for distinguishing purposes. It also incurs a nominal performance cost, as the first character of each key needs to be inspected and possibly modified.Declaration
Swift
case firstLetterLower
-
Convert the first letter of the key to upper case before attempting to match a key with the one specified by each type. For example,
oneTwoThree
becomesOneTwoThree
.Note
This strategy should be used when the keys are expected to start with a lowercase letter and need to be converted to start with an uppercase letter. It incurs a nominal performance cost, as the first character of each key needs to be inspected and possibly modified.Declaration
Swift
case firstLetterUpper