Created
August 5, 2020 23:06
-
-
Save emma-k-alexandra/2f0f627b04f1306d93351c365aa7a827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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