如何在swift 3.0中将此类参数发送到服务器调用

时间:2017-04-15 07:24:39

标签: ios json swift3

我需要将以下参数发送到swift 3.0中的服务器。如何构建请求参数?

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

2 个答案:

答案 0 :(得分: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)

答案 1 :(得分:-1)

您好,我不确定它是否有效,但无论如何,试试这个

let params: ["step_1": [["name": "Some name",
                  "mobile": "12345678",
                  "line_1": "line_1 stuff",
                  "...": "..."]]]