Hi there everyone,
Im trying to iterate this kind on array and initiate the Response Struct with no succes,
help would be much appriciated.
let decoded:[String:Any] = ["message-count": "1", "messages": [["message-price": "0.01880000", "status": "0", "network": "42501", "to": "123456789", "message-id": "0D0000005B86A343", "remaining-balance": "8.65950000"]]]
struct Response:Decodable {
let messageCount:Int?
let messages:[Messages]
}
struct Messages:Decodable {
let status:Int?
let messageId:String?
let to:String?
let remainingBalance:Float?
let messagePrice:Float?
let network:String?
/
init(json:[String:Any]) {
status = json["status"] as? Int ?? -1
messageId = json["message-id"] as? String ?? ""
to = json["to"] as? String ?? ""
remainingBalance = json["remaining-balance"] as? Float ?? 0.0
messagePrice = json["message-price"] as? Float ?? 0.0
network = json["network"] as? String ?? ""
}
}