Skip to content

Instantly share code, notes, and snippets.

@sajjadsarkoobi
Last active July 18, 2020 07:54
Show Gist options
  • Save sajjadsarkoobi/cb032fae96682ebc70f087af2d16cf12 to your computer and use it in GitHub Desktop.
Save sajjadsarkoobi/cb032fae96682ebc70f087af2d16cf12 to your computer and use it in GitHub Desktop.
struct user_Model:Codable {
var fullName:AnyCodableValue?
var age:AnyCodableValue?
var point:AnyCodableValue?
var isVerified:AnyCodableValue?
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.fullName = try container.decodeIfPresent(AnyCodableValue.self, forKey: .fullName)
self.age = try container.decodeIfPresent(AnyCodableValue.self, forKey: .age)
self.point = try container.decodeIfPresent(AnyCodableValue.self, forKey: .point)
self.isVerified = try container.decodeIfPresent(AnyCodableValue.self, forKey: .isVerified)
}
init(){
self.fullName = .string("")
self.age = .integer(0)
self.point = .double(0)
self.isVerified = .boolean(false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment