我有3個數組,當我在表中插入數據時,數據也添加到數組中(鍵值對)。如何在ios swift中創建json對象
var person = ["ABC","XYZ","PQR"]
var email = ["[email protected]","[email protected]","[email protected]"]
var mobile = ["1234567890","1234567890","1234567890"]
我的問題是如何創建JSON對象和數據存儲鍵值對。
我想要這個
{
"blogs": [
{
"person": "ABC",
"email": "[email protected]",
"contact": "1234567890"
},
{
"person": "XYZ",
"email": "[email protected]",
"contact": "1234567890"
},
{
"person": "PQR",
"email": "[email protected]",
"contact": "1234567890"
}
]
}
,使得數據傳送到url()
在操作按鈕,在陣列和臺增加數據
@IBAction func meeting_info(_ sender: Any) {
var PersonName = person_name.text
var Email = email_id.text
var MobileNo = mobile_no.text
if (person_name.text?.isEmpty)! || (email_id.text?.isEmpty)! || (mobile_no.text?.isEmpty)! {
displayMyAlertMessage(userMessage: "please check field empty or not");
}
else{
person.append(person_name.text!)
email.append(email_id.text!)
mobile.append(mobile_no.text!)
meetingTableView.reloadData()
}
}
我要生成從人JSON數組,電子郵件和關鍵值對中的聯繫人
我在一個paramerter傳遞你的價值就像 –
VAR SSS = [ 「CUTOMER名」: 「XYZ」, 「日期」: 「13-08-2017」 「blogs」:array] as [String:Any] and coverter into jsonobject and that jsonobject pass to post web service.any probelm for future process –