Created
March 15, 2016 05:19
-
-
Save kgn/ffe36a3cf61dcde18bb4 to your computer and use it in GitHub Desktop.
Crazy JSON parsing in Swift
This file contains hidden or 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
let twitterUser: String? | |
if let data = serverResponse { | |
if let json = try? NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String: AnyObject] { | |
if let user = json?["user"] as? [String: AnyObject] { | |
if let accounts = user["accounts"] as? [AnyObject] { | |
if let twitter = accounts.first as? [String: AnyObject] { | |
twitterUser = twitter["user"] as? String | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment