Files
Argo/ArgoTests/JSON/JSONFileReader.swift
Tony DiPasquale bf726b714c Update the documentation for Swift 2
This also breaks up the main README.md into a Documentations directory
with separate documents for different topics. This will be expanded upon
with new PRs going forward.
2015-09-18 16:59:42 -07:00

14 lines
404 B
Swift

import Foundation
func JSONFromFile(file: String) -> AnyObject? {
return NSBundle(forClass: JSONFileReader.self).pathForResource(file, ofType: "json")
.flatMap { NSData(contentsOfFile: $0) }
.flatMap(JSONObjectWithData)
}
private func JSONObjectWithData(data: NSData) -> AnyObject? {
return try? NSJSONSerialization.JSONObjectWithData(data, options: [])
}
private class JSONFileReader { }