Skip to content

Instantly share code, notes, and snippets.

@emma-k-alexandra
Created August 5, 2020 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emma-k-alexandra/2f0f627b04f1306d93351c365aa7a827 to your computer and use it in GitHub Desktop.
Save emma-k-alexandra/2f0f627b04f1306d93351c365aa7a827 to your computer and use it in GitHub Desktop.
import Foundation
struct Example: Codable {
let id: Int
var text: String
}
let json = """
{
"id": 1,
"text": "Hello, world!"
}
""".data(using: .utf8)!
try JSONDecoder().decode(Example.self, from: json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment