Skip to content

Instantly share code, notes, and snippets.

@jarsen
Last active June 6, 2017 17:20
Show Gist options
  • Select an option

  • Save jarsen/8f574d75ee86c5b8b56039bfe5eb432a to your computer and use it in GitHub Desktop.

Select an option

Save jarsen/8f574d75ee86c5b8b56039bfe5eb432a to your computer and use it in GitHub Desktop.
Unmarshaling
struct User: Unmarshaling {
var id: Int
var name: String
var email: String
init(object: MarshaledObject) throws {
id = try object.value(for: "id")
name = try object.value(for: "name")
email = try object.value(for: "email")
}
}
let users: [User] = try json.value(for: "users")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment