Last active
February 8, 2018 10:39
-
-
Save harshvishu/29a3414e01e19de92fac079520912148 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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