Created
March 1, 2015 04:24
-
-
Save jquave/77d9b69a5aa08119f76d 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
// Complete code using LumaJSON | |
if let parsed = LumaJSON.parse(jsonStr) { | |
if let friend_ids = parsed["friend_ids"] as? [Int] { | |
println("Luma count: \(friend_ids.count)") | |
} | |
} | |
// Same functionality using built-in tools | |
var err: NSError? | |
if let jsonDeserialized = NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableLeaves, error: &err) as? NSDictionary { | |
if let friend_ids = jsonDeserialized["friend_ids"] as? [Int] { | |
println("Native count: \(friend_ids.count)") | |
} | |
} | |
else if (err != nil) { | |
println(err?.localizedDescription) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment