Daily iOS
Networking

Predicting a Codable decode

What happens when you run this Codable decoding code?

struct Item: Decodable {
    let id: Int
    let name: String?
    let price: Double
}
let json = #"{"id": 1, "name": null, "price": "9.99"}"#
let item = try JSONDecoder().decode(Item.self, from: Data(json.utf8))

Pick one

Submit