Skip to content

Instantly share code, notes, and snippets.

@issuran
Last active October 17, 2023 18:49
Show Gist options
  • Save issuran/7c36890f768b22145b582837e128b118 to your computer and use it in GitHub Desktop.
Save issuran/7c36890f768b22145b582837e128b118 to your computer and use it in GitHub Desktop.
Playground to validate model/response faster
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