swift 字典转json字符串
2016-10-24 本文已影响0人
func_老衲姓罗
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
}