Skip to content

Instantly share code, notes, and snippets.

@pgpt10
Last active November 4, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgpt10/4f8fc3ed32c052109d97b0530f341a0d to your computer and use it in GitHub Desktop.
Save pgpt10/4f8fc3ed32c052109d97b0530f341a0d to your computer and use it in GitHub Desktop.
let jsonString = """
{
"type":"fruit",
"size":{
"width":150,
"height":150
},
"name":"Apple",
"link":"https:\\/\\/www.fruits.com\\/apple",
"isSample":true,
"metaData":{
"color":"green"
},
"format":"gif"
}
"""
if let jsonData = jsonString.data(using: .utf8)
{
let photoObject = try? JSONDecoder().decode(Photo.self, from: jsonData)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment