Skip to content

Instantly share code, notes, and snippets.

@pgpt10
Last active November 4, 2017 17:39
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/40863d7140fcf88462cf5e4504eed141 to your computer and use it in GitHub Desktop.
Save pgpt10/40863d7140fcf88462cf5e4504eed141 to your computer and use it in GitHub Desktop.
let jsonString = """
{
"type":"fruit",
"size":{
"width":150,
"height":150
},
"title":"Apple",
"url":"https:\\/\\/www.fruits.com\\/apple",
"isSample":true,
"metaData":{
"color":"green"
}
}
"""
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