Last active
April 13, 2018 21:00
-
-
Save garsdle/54da2a6ffdac13f1cf36f361d5d7f311 to your computer and use it in GitHub Desktop.
Codable Mapping
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: Codable { | |
let id: Int | |
let name: String | |
enum CodingKeys: String, CodingKey { | |
case id | |
case name = "user_name" | |
} | |
} | |
let user = try? JSONDecoder().decode(User.self, from: jsonData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment