Skip to content

Instantly share code, notes, and snippets.

@harshvishu
Last active February 8, 2018 10:39
Show Gist options
  • Save harshvishu/29a3414e01e19de92fac079520912148 to your computer and use it in GitHub Desktop.
Save harshvishu/29a3414e01e19de92fac079520912148 to your computer and use it in GitHub Desktop.
struct User: Decodable, CustomStringConvertible {
let username: String
let name: String
/// This is the key part
/// If parameters and variable name differ
/// you can specify custom key for mapping "eg. 'user_name'"
enum CodingKeys: String, CodingKey {
case username = "user_name"
case name
}
var description: String {
return "User: { username: \(username), name: \(name) }"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment