Skip to content

Instantly share code, notes, and snippets.

@agiletalk
Created August 30, 2019 15:35
Show Gist options
  • Save agiletalk/7d81df5d2a8787262be3438c2e2687ca to your computer and use it in GitHub Desktop.
Save agiletalk/7d81df5d2a8787262be3438c2e2687ca to your computer and use it in GitHub Desktop.
import Foundation
struct Repo: Decodable {
let name: String
let private: Bool
let language: String
}
let json = """
[
{
"name": "SignUp",
"private": false,
"language": "Swift"
},
{
"name": "tomate",
"private": false,
"language": "Swift"
},
{
"name": "springmemo",
"private": false,
"language": "Python"
}
]
""".data(using: .utf8)!
let repos = try JSONDecoder().decode([Repo].self, from: json)
repos.forEach { print($0) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment