I have this JSON respone:
{
"success": false,
"message": {
"gender": [
"The gender field is required."
],
"sms_token": [
"The sms token field is required."
]
}
}
note that the message object could have more than two elements...
and I'm trying to get the array inside message object... I have tried this:
guard let messages = receivedTodo["message"] as? String, let message = receivedTodo["sms_token"] as? String else {
print("Could not get messages from JSON")
return
}
print("The error is:" + message)
}
but this didn't work and i will always get "could not get messages from JSON"...
I want to loop and get all of the elements inside message object and print them out.. how to archive this?