Skip to content

Instantly share code, notes, and snippets.

@KarenK1995
Last active March 24, 2020 17:06
Show Gist options
  • Save KarenK1995/2b5cc131fe0d29e23b224e2d3ccd3f64 to your computer and use it in GitHub Desktop.
Save KarenK1995/2b5cc131fe0d29e23b224e2d3ccd3f64 to your computer and use it in GitHub Desktop.
struct User: Codable {
let name: String
let surname: String
let age: Int
}
let user = User(name: "John", surname: "Smith", age: 18)
do {
let userData = try JSONEncoder().encode(user)
}
catch {
print(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment