user1585121
user1585121

Reputation:

How to convert a String array to Swiftyjson JSON type

I need to pass an array of string/Int (doesnt matter) as JSON parameter in a HTTP body for a POST request.

{
  "par1" : value,
  "par2" : "value2",
  "par3" : ['123:456', '123:234' ...]*
}

*My problem is for filling my JSON object with param3 values. In the swift code I have them as an array of Strings.

There are many example of converting a JSON object back to an array of strings/Int, but I can't find it the other way around.

Upvotes: 0

Views: 814

Answers (1)

user1585121
user1585121

Reputation:

As mentioned in the comments, the way to go is to use NSJSONSerialization to generate object encoded in JSON data.

Upvotes: 0

Related Questions