swift 字典转json字符串

func toJSONString(dict:NSDictionary?)->String{

let data = try? NSJSONSerialization.dataWithJSONObject(dict!, options: NSJSONWritingOptions.PrettyPrinted)

let strJson = NSString(data: data!, encoding: NSUTF8StringEncoding)

return strJson! as String

}

推荐阅读更多精彩内容