swift dictonary convert to (转为 )json

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 dictonary convert to (转为 )json)