Last active
December 16, 2015 12:08
-
-
Save sergdort/a3dd93f024185c46543c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public typealias JSON = AnyObject | |
public typealias JSONDictionary = Dictionary<String, JSON> | |
public typealias JSONArray = Array<JSON> | |
public func JSONObjectWithData(data: NSData) -> AnyObject? { | |
do { return try NSJSONSerialization.JSONObjectWithData(data, options: []) } | |
catch { return .None } | |
} | |
public func JSONString(object: JSON) -> String? { | |
return object as? String | |
} | |
public func JSONObject(object: JSON) -> JSONDictionary? { | |
return object as? JSONDictionary | |
} | |
public func JSONObjects(object:JSON) -> [JSONDictionary]? { | |
return object as? [JSONDictionary] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment