Enumeration
XMLDecoder.KeyDecodingStrategy
public enum KeyDecodingStrategy
The strategy to use for automatically changing the box of keys before decoding.
Relationships
Member Of
XMLDecoderXMLDecoderfacilitates the decoding of XML into semanticDecodabletypes.
Enumeration Cases
useDefaultKeys
case useDefaultKeys
Use the keys specified by each type. This is the default strategy.
convertFromSnakeCase
case convertFromSnakeCase
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_threebecomesoneTwoThree._one_two_three_becomes_oneTwoThree_.
convertFromKebabCase
case convertFromKebabCase
Convert from "kebab-case" to "kebabCase" before attempting to match a key with the one specified by each type.
custom
case custom((_ codingPath: [CodingKey]) -> CodingKey)
Provide a custom conversion from the key in the encoded XML to the keys specified by the decoded types. The full path to the current decoding position is provided for context (in case you need to locate this key within the payload). The returned key is used in place of the last component in the coding path before decoding. If the result of the conversion is a duplicate key, then only one box will be present in the container for the type to decode from.