Skip to content

Instantly share code, notes, and snippets.

View sbishopwta's full-sized avatar

Steven Bishop sbishopwta

  • San Francisco, CA
View GitHub Profile
@sbishopwta
sbishopwta / gist:82b1726bc50992583dde04693de0515e
Created September 9, 2016 16:00
Swift 3 - Load JSON file
let filePath = Bundle.main.pathForResource("YOUR_FILE_NAME", ofType: "json", inDirectory: nil)
if let filePath = filePath {
do {
let fileUrl = URL(fileURLWithPath: filePath)
let jsonData = try Data(contentsOf: fileUrl, options: .mappedIfSafe)
let json = try? JSONSerialization.jsonObject(with: jsonData)
} catch {
print(error)
fatalError("Unable to read contents of the file url")