Last active
October 17, 2023 18:49
-
-
Save issuran/7c36890f768b22145b582837e128b118 to your computer and use it in GitHub Desktop.
Playground to validate model/response faster
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 UIKit | |
// TEST MODEL HERE | |
struct TestModel: Codable { | |
let name: String | |
let ages: [String] | |
enum CodingKeys: String, CodingKey { | |
case name = "nome" | |
case ages = "idades" | |
} | |
} | |
let okData = """ | |
{ | |
"nome": "Tiago", | |
"idades": ["1", "2", "3"] | |
} | |
""".data(using: .utf8)! | |
let decoder = JSONDecoder() | |
let okResult = try decoder.decode(TestModel.self, from: okData) | |
print(okResult) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment