Taking a Second Look at Creating JSON Friendly Dictionaries in Swift

Earlier today I published a bunch of blog posts on how to create dictionaries in Swift that can easily be turned into JSON using the Alamofire networking library/wrapper for iOS. While I was trying to figure all of this stuff out earlier today I was primarily using the web based repl.it environment. However, after taking a second look at things it looks like using repl.it to do all of my testing may have been one of the big reasons why my solution ended up being much more complex than I would have imagined necessary.
After taking a step back and approaching the problem with a fresh perspective, it appears Alamofire has a built in class called “Parameters” which makes it easy to create JSON friendly dictionaries in Swift. Apparently however, I didn’t attempt to use this convenient class because I was doing all my hacking in the web browser and the actual Alamofire library and Parameters class was not available to me. So now I know: just use the Parameters class and creating JSON objects in Swift shouldn’t be all that complicated (maybe a little complicated, but not too bad).

 

topherPedersen