Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public struct Customer: Decodable {
- let name: String
- let accountNumber: Int
- let archived: Bool
- private enum CodingKeys: String, CodingKey {
- case name
- case accountNumber
- case archived
- }
- public init(from decoder: Decoder) throws {
- let container = try decoder.container(keyedBy: CodingKeys.self)
- name = try container.decode(String.self, forKey: .name)
- accountNumber = try container.unwrapAndDecode(Int.self, forKey: .accountNumber)
- archived = try container.unwrapAndDecode(Bool.self, forKey: .archived)
- }
- }
Add Comment
Please, Sign In to add comment