简体   繁体   中英

Swift - Alamofire .POST with parameters problem

I want to sent a request with parameters, and I've a problem with the parameters sequence. I need to sent something like that:

 let parameters: Parameters = [
                     "name":"someName",
                     "parameters": {
                        "searchingMore": "[{\"name\": \"\(items.name)\",\"surname\": \"\(items.surname)\"}]"
                }] as Dictionary

And I'm always getting the Consecutive statements on a line must be separated by ';'and Expected expression problem on the searchingMore line. I just want to know how to send the table as a parameter.

Try replacing the scopes {} with [] as follows -

let parameters: Parameters = [
            "name":"someName",
            "parameters": [
                "searchingMore": "[{\"name\": \"\(items.name)\",\"surname\": \"\(items.surname)\"}]"
            ]
        ] as Dictionary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM