2017-04-15 58 views
-1

我需要將這個參數發送到服務器在swift 3.0。我如何構建請求參數?如何發送這種類型的參數到服務器調用swift 3.0

"step_1": [ 
     { 
      "name": "", 
      "mobile": "", 
      "line_1": "", 
      "line_2": "", 
      "city": "", 
      "state": "", 
      "pincode": "", 
      "fax": "", 
      "gst": "", 
      "owner_name": "", 
      "dob": "", 
      "anniversary": "" 
     } 
    ] 
+2

你已經試過沒??? –

+1

使用SwiftyJSON。 – Sweeper

+0

這取決於服務器期望的數據類型。 – vadian

回答

0

對於低於上JSON數據字典代碼:

let param = [["name": "abc", 
"mobile": "123", 
"line_1": "line_1", 
"line_2": "line_2", 
"city":"xyz", 
"state":"abc", 
"pincode":"000", 
"fax":"123", 
"gst":"gst", 
"ownwer_name":"ownwer_name", 
"dob":"xx-xx-xxxx", 
"anniversary":"xx-xx-xxxx"]] 

//Print data 
print(param[0]["name"] as! String) 
+0

嗨Sakir Sherasiya ...謝謝你給我答案,但它是不正確的格式,因爲我顯示上面的數據。字典開始與'{'花括號可以請你檢查一次 – suri

+0

它是正確的格式 –

+0

你採取step_1作爲父母和其他所有孩子都是正確的 –

-1

嗨,我不知道這是否會工作,但不管怎麼說,試試這個

let params: ["step_1": [["name": "Some name", 
        "mobile": "12345678", 
        "line_1": "line_1 stuff", 
        "...": "..."]]] 
相關問題