Skip to content

Instantly share code, notes, and snippets.

Created June 23, 2015 17:21
Show Gist options
  • Save anonymous/a167148a8a6d169292ff to your computer and use it in GitHub Desktop.
Save anonymous/a167148a8a6d169292ff to your computer and use it in GitHub Desktop.
Swift 1.2 : Json Array Parsing
let url=NSURL(string:"http://dl-8.one2up.com/onetwo/content/2015/6/15/9c3b51249fbbe20ca9d841401e276d97.php")
let allContactsData=NSData(contentsOfURL:url!)
var allContacts: AnyObject! = NSJSONSerialization.JSONObjectWithData(allContactsData!, options: NSJSONReadingOptions(0), error: nil)
if let json = allContacts as? Array<AnyObject> {
print("JSON: \(json)")
for index in 0...json.count-1 {
let contact : AnyObject? = json[index]
let collection = contact! as! Dictionary<String, AnyObject>
let name : AnyObject? = collection["AnimeName"]
let cont : AnyObject? = collection["Episodes"]
names.append(name as! String)
episodes.append(cont as! String)
}
}
println(names)
println(episodes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment