Skip to content

Instantly share code, notes, and snippets.

@alvaroroyo
Created February 28, 2019 09:31
Show Gist options
  • Save alvaroroyo/fbb09dc3b2f5a8454c525831a4ddb419 to your computer and use it in GitHub Desktop.
Save alvaroroyo/fbb09dc3b2f5a8454c525831a4ddb419 to your computer and use it in GitHub Desktop.
let url = Bundle.main.url(forResource: "persons", withExtension: "json")
let fileData = try! Data(contentsOf: url!)
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(DateFormatter.bornDate)
let persons:[Person] = try! decoder.decode([Person].self, from: fileData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment