Created
May 14, 2016 08:59
-
-
Save b3ll/75959235c67e0cd147504146e17a2cfa to your computer and use it in GitHub Desktop.
Blazingly-Fast JSON Parser written in Swift
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
import Foundation | |
public typealias JSON = AnyObject | |
public func JSONWithData(data: NSData) -> JSON? { | |
do { | |
let j = try NSJSONSerialization.JSONObjectWithData(data, options: []) | |
return j | |
} catch _ { | |
return nil | |
} | |
} |
Still too complicated. You could've written it in two lines:
import Foundation
let JSONWithData: NSData -> AnyObject? = { try? NSJSONSerialization.JSONObjectWithData($0, options: []) }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's way too much complicated. You could have written it in 3 lines only.