Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created March 13, 2018 09:58
Show Gist options
  • Save vialyx/a8ebbd0b3ec739561e8cf78018760029 to your computer and use it in GitHub Desktop.
Save vialyx/a8ebbd0b3ec739561e8cf78018760029 to your computer and use it in GitHub Desktop.
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