Skip to content

Instantly share code, notes, and snippets.

@charliefulton
Created March 3, 2016 20:20
Show Gist options
  • Save charliefulton/a41fb88906036dfc5f26 to your computer and use it in GitHub Desktop.
Save charliefulton/a41fb88906036dfc5f26 to your computer and use it in GitHub Desktop.
open json file from resources of playground
//: Playground - noun: a place where people can play
import Foundation
let currentPath = NSBundle.mainBundle().bundlePath
let file = currentPath + "/en_MediaComponents.json"
if let jsonData = NSData(contentsOfFile: file) {
do {
if let jsonResult: NSDictionary = try NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions.AllowFragments) as? NSDictionary
{
if let mediaItems = jsonResult["_embedded"]!["mediaComponents"] as? [[String:AnyObject]] {
}
}
} catch {
print("could not load json from file: \(file)")
} // end json
} else {
print("no data")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment