Skip to content

Instantly share code, notes, and snippets.

@garsdle
Last active April 13, 2018 21:00
Show Gist options
  • Save garsdle/54da2a6ffdac13f1cf36f361d5d7f311 to your computer and use it in GitHub Desktop.
Save garsdle/54da2a6ffdac13f1cf36f361d5d7f311 to your computer and use it in GitHub Desktop.
Codable Mapping
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