Я получаю JSON
данные от API, и я получаю ответ успешно, но есть некоторая проблема для меня, как сначала получить прямое значение без ключа, позвольте мне показать вам мой ответ
Ответ
{
"message": "Notification Sent Successfully.",
"success": "1",
"message_list": [
{
"+919722552298": [
{
"body": "Sent from your Twilio trial account - This is test message by purvesh",
"from": "",
"sid": "",
"status": "sent",
"date_updated": "Mon, 01 Jul 2019 12:58:49 +0000",
"date_sent": "Mon, 01 Jul 2019 12:58:49 +0000",
"date_created": "Mon, 01 Jul 2019 12:58:49 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is test message by purvesh",
"from": "",
"sid": "",
"status": "sent",
"date_updated": "Sat, 29 Jun 2019 09:36:07 +0000",
"date_sent": "Sat, 29 Jun 2019 09:36:07 +0000",
"date_created": "Sat, 29 Jun 2019 09:36:07 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is test message by purvesh",
"from": "",
"sid": "",
"status": "sent",
"date_updated": "Sat, 29 Jun 2019 09:35:18 +0000",
"date_sent": "Sat, 29 Jun 2019 09:35:18 +0000",
"date_created": "Sat, 29 Jun 2019 09:35:18 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test message...",
"from": "",
"sid": "",
"status": "sent",
"date_updated": "Sat, 29 Jun 2019 05:56:43 +0000",
"date_sent": "Sat, 29 Jun 2019 05:56:43 +0000",
"date_created": "Sat, 29 Jun 2019 05:56:43 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test...",
"from": "",
"sid": "",
"status": "sent",
"date_sent": "Thu, 27 Jun 2019 11:52:44 +0000",
"date_created": "Thu, 27 Jun 2019 11:52:43 +0000",
"date_updated": "Thu, 27 Jun 2019 11:52:44 +0000",
"to": ""
}
]
},
{
"+61459036405": [
{
"body": "Sent from your Twilio trial account - Thanks for the message. Configure your number's SMS URL to change this message.Reply HELP for help.Reply STOP to unsubscribe.Msg&Data rates may apply.",
"from": "",
"sid": "",
"status": "delivered",
"date_sent": "Sat, 29 Jun 2019 06:25:33 +0000",
"date_created": "Sat, 29 Jun 2019 06:25:33 +0000",
"date_updated": "Sat, 29 Jun 2019 06:25:35 +0000",
"to": ""
},
{
"body": "Hello Ron ",
"from": "",
"sid": "",
"status": "received",
"date_sent": "Sat, 29 Jun 2019 06:25:33 +0000",
"date_created": "Sat, 29 Jun 2019 06:25:33 +0000",
"date_updated": "Sat, 29 Jun 2019 06:25:33 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test message...",
"from": "",
"sid": "",
"date_updated": "Sat, 29 Jun 2019 06:08:42 +0000",
"date_created": "Sat, 29 Jun 2019 06:08:42 +0000",
"status": "sent",
"date_sent": "Sat, 29 Jun 2019 06:08:42 +0000",
"to": ""
}
]
},
{
"+918733009842": [
{
"body": "Sent from your Twilio trial account - This is a test...",
"from": "",
"sid": "",
"date_updated": "Thu, 27 Jun 2019 12:32:45 +0000",
"date_created": "Thu, 27 Jun 2019 12:32:45 +0000",
"status": "sent",
"date_sent": "Thu, 27 Jun 2019 12:32:45 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test...",
"from": "",
"sid": "",
"status": "sent",
"date_created": "Thu, 27 Jun 2019 12:25:37 +0000",
"date_updated": "Thu, 27 Jun 2019 12:25:37 +0000",
"date_sent": "Thu, 27 Jun 2019 12:25:37 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test...",
"from": "",
"sid": "",
"status": "sent",
"date_created": "Thu, 27 Jun 2019 12:07:04 +0000",
"date_updated": "Thu, 27 Jun 2019 12:07:04 +0000",
"date_sent": "Thu, 27 Jun 2019 12:07:04 +0000",
"to": ""
},
{
"body": "Sent from your Twilio trial account - This is a test...",
"from": "",
"sid": "",
"status": "sent",
"date_created": "Thu, 27 Jun 2019 12:01:55 +0000",
"date_updated": "Thu, 27 Jun 2019 12:01:55 +0000",
"date_sent": "Thu, 27 Jun 2019 12:01:55 +0000",
"to": ""
}
]
}
]
}
вот мой ответ, и теперь я покажу вам, что я успешно получаю данные массива message_list
, но проблема заключается в том, как получить номер телефона, который является основным массивом, как вы показываете в моем ответеЯ хочу список номеров, который является массивом в массиве списка побочных сообщений
func messageListAPI(){
let preferences = UserDefaults.standard
let uid = "u_id"
let acTkn = "acc_tkn"
let u_ID = preferences.object(forKey: uid)
let A_Token = preferences.object(forKey: acTkn)
let params = ["user_id": u_ID!,"access_token": A_Token!,"twilio_number": "+13344313181"]
// print(params)
Alamofire.request(messagelist, method: .post, parameters: params).responseJSON(completionHandler: {(response) in
switch response.result{
case.success(let value):
let json = JSON(value)
print(json)
let message = json["message"].stringValue
let success = json["success"].stringValue
let data = json["message_list"]
let model = ResponseModel(message: message, success: success, messageList: data) // Here i am getting error
case.failure(let error):
print(error.localizedDescription)
}
})
}
Вот мой метод вызова API, который я получаю message_list
, успешно любой может помочь мне получить список номеров