import UIKit
import AVFoundation
let dictionary = ["aKey": "aValue", "anotherKey": "anotherValue"]
let theJSONData = NSJSONSerialization.dataWithJSONObject(
dictionary ,
options: NSJSONWritingOptions(0),
error: nil)
let theJSONText = NSString(data: theJSONData!,
encoding: NSASCIIStringEncoding)
println("JSON string = \(theJSONText!)")
放在playground 可以看看OK?哈哈
本文介绍了如何在Swift中使用NSJSONSerialization将字典序列化为JSON字符串的过程,包括实例代码演示。
1420

被折叠的 条评论
为什么被折叠?



