Created
March 13, 2018 09:58
-
-
Save vialyx/a8ebbd0b3ec739561e8cf78018760029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let jsonURL = classBundle.url(forResource: "users", withExtension: "json"), | |
let data = try? Data(contentsOf: jsonURL), | |
let objects = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.allowFragments) else { fatalError("haven't users.json file") } | |
print("objects: \(objects)") | |
/* | |
objects: { | |
users = ( | |
{ | |
id = 190; | |
name = "Maxim Vialyx"; | |
}, | |
{ | |
id = 341; | |
name = "Medium Guest"; | |
}, | |
{ | |
id = 254; | |
name = "Funny Monkey"; | |
} | |
); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment