iosarraysswiftalamofire

How to send array data to API with Alamofire?


These are my parameters send to API:

let params : [String : Any]  = [
      "interests" : interestParams
]

and output of params is like this:

[interests : ["Olahraga", "Sains", "Musik"]]

I need to send parameters like this:

{ "interests": ["Olahraga", "Sains", "Musik"] }

Solution

  • I do it like this way all of the time Xcode will not print the json like you want

    { "interests": ["Olahraga", "Sains", "Musik"] }
    

    but in actutal it will send data in this form to server in the request.

    So don't worry that Xcode is displaying like this

    [interests : ["Olahraga", "Sains", "Musik"]]