mirror of
https://github.com/zhigang1992/Argo.git
synced 2026-04-29 13:25:41 +08:00
Remove Runes dependency from the playground
This commit is contained in:
committed by
Tony DiPasquale
parent
f184851164
commit
16bdb90332
@@ -5,15 +5,14 @@
|
||||
*/
|
||||
import Foundation
|
||||
import Argo
|
||||
import Runes
|
||||
import Curry
|
||||
/*:
|
||||
**Helper function** – load JSON from a file
|
||||
*/
|
||||
func JSONFromFile(file: String) -> AnyObject? {
|
||||
return NSBundle.mainBundle().pathForResource(file, ofType: "json")
|
||||
>>- { NSData(contentsOfFile: $0) }
|
||||
>>- JSONObjectWithData
|
||||
.flatMap { NSData(contentsOfFile: $0) }
|
||||
.flatMap(JSONObjectWithData)
|
||||
}
|
||||
|
||||
func JSONObjectWithData(data: NSData) -> AnyObject? {
|
||||
@@ -50,6 +49,6 @@ extension User: Decodable {
|
||||
/*:
|
||||
* * *
|
||||
*/
|
||||
let user: User? = JSONFromFile("user_with_email") >>- decode
|
||||
let user: User? = JSONFromFile("user_with_email").flatMap(decode)
|
||||
print(user!)
|
||||
|
||||
|
||||
@@ -5,15 +5,14 @@
|
||||
*/
|
||||
import Foundation
|
||||
import Argo
|
||||
import Runes
|
||||
import Curry
|
||||
/*:
|
||||
**Helper function** – load JSON from a file
|
||||
*/
|
||||
func JSONFromFile(file: String) -> AnyObject? {
|
||||
return NSBundle.mainBundle().pathForResource(file, ofType: "json")
|
||||
>>- { NSData(contentsOfFile: $0) }
|
||||
>>- JSONObjectWithData
|
||||
.flatMap { NSData(contentsOfFile: $0) }
|
||||
.flatMap(JSONObjectWithData)
|
||||
}
|
||||
|
||||
func JSONObjectWithData(data: NSData) -> AnyObject? {
|
||||
@@ -63,6 +62,6 @@ extension App: Decodable {
|
||||
/*:
|
||||
* * *
|
||||
*/
|
||||
let app: App? = (JSONFromFile("tropos")?["results"] >>- decode)?.first
|
||||
let app: App? = (JSONFromFile("tropos")?["results"].flatMap(decode))?.first
|
||||
print(app!)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user