How to convert NSDictionary to Json String in Swift ( iOS, Xcode )? [duplicate]
No need to implement this kind of complex logic,
You can simply do this
var jsonData: NSData = NSJSONSerialization.dataWithJSONObject(dictionary, options: NSJSONWritingOptions.PrettyPrinted, error: &error)! if error == nil { return NSString(data: jsonData, encoding: NSUTF8StringEncoding)! as String }
and if you want to send it with API to server , no need to even convert it to String