Hi There im triyng to decode the following json to a Type:Response, but i dont know what im doing wrong.
can anyone point me out to the solution.
Help would be much appriciated.
let json = """
[
{
"status_message": "Success",
"current_carrier": {
"network_code": "US-FIXED",
}
]
""".data(using:.utf8)!
struct Response:Codable{
var status_message:String
var current_carrier:CurrentCarrier
struct CurrentCarrier:Codable{
var network_code:String
}
}
let decoder = JSONDecoder()
let response = try decoder.decode([Response].self, from: json)
for i in response {
print(i.status_message)
print(i.current_carrier.network_code)
}