cercato di ottenere questo a lavorare in Swift 2.0, l'errore dice:Usa NSSerialization.datawithJSON a Swift 2
tipo NSJSONWritingOptions non possono essere conformi al protocollo NilLiteralConvertible
a var options = prettyPrinted...
:
func JSONStringify(value: AnyObject,prettyPrinted:Bool = false) -> String {
var options = prettyPrinted ? NSJSONWritingOptions.PrettyPrinted : nil
if NSJSONSerialization.isValidJSONObject(value) {
do{
let data = try NSJSONSerialization.dataWithJSONObject(value, options: options)
if let string = NSString(data: data, encoding: NSUTF8StringEncoding) {
return string as String
}
} catch {
}
}
return ""
}