JSONConverter
public struct JSONConverter
A simple casing converter for dictionary keys, converting either from snake_case
to camelCase, or from camelCase to snake_case.
-
Enum definining the supported JSON conversions
See moreDeclaration
Swift
public enum Conversion -
Perform the specified casing
conversionon the keys indictionary, as governed by theJSONCache.casingsettingDeclaration
Swift
public static func convert(_ conversion: Conversion, dictionary: [String : Any], qualifier: String? = nil) -> [String : Any]Parameters
conversionEnum specifying if the conversion is from JSON or to JSON.
dictionaryThe dictionary whose keys are to be converted.
qualifierA string qualifier to prefix onto any reserved words among JSON keys when converting from JSON, or to strip away from reserved words when converting to JSON. Defaults to
nilif not given. If for instance the qualifier isEntityName, the JSON keydescriptionwill be converted toentityNameDescription. Conversely, the dictionary keyentityNameDescriptionwill be converted to the JSON keydescription. The keysomeOtherDescription, however, will be converted tosome_other_description(or not converted at all ifJSONCache.casingis.camelCase). Ifqualifieris not given, any string that ends with-Descriptionwill be converted todescriptionwhen converting to JSON. Qualification and dequalification of reserved words is done regardless of whetherJSONCache.casingspecifiessnake_caseorcamelCase. -
Perform the specified casing
conversiononstring, as governed by theJSONCache.casingsettingDeclaration
Swift
public static func convert(_ conversion: Conversion, string: String, qualifier: String? = nil) -> StringParameters
conversionEnum specifying if the conversion is from JSON or to JSON.
stringThe string to be converted.
qualifierA string qualifier to prefix onto the string when converting from JSON and the string represents a reserved word, or to strip away from the string when converting to JSON. Defaults to
nilif not given. If for instance the qualifier isEntityName, the reserved worddescriptionwill be converted toentityNameDescriptionwhen converting from JSON. Conversely, the stringentityNameDescriptionwill be converted todescriptionwhen converting to JSON. The stringsomeOtherDescription, however, will be converted tosome_other_description(or not converted at all ifJSONCache.casingis.camelCase). Ifqualifieris not given, any string that ends with-Descriptionwill be converted todescriptionwhen converting to JSON. Qualification and dequalification of reserved words is done regardless of whetherJSONCache.casingspecifiessnake_caseorcamelCase.
View on GitHub
JSONConverter Structure Reference