Skip to content

Instantly share code, notes, and snippets.

@ikesyo
Created June 23, 2015 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ikesyo/dbbe8cedfc8e909cfd38 to your computer and use it in GitHub Desktop.
Save ikesyo/dbbe8cedfc8e909cfd38 to your computer and use it in GitHub Desktop.
import Himotoki
struct User: Decodable { ... }
struct Foo: Decodable {
let name: String
let users: [User]
static func decode(e: Extractor) -> Foo? {
let create = { Foo($0) }
return build(
e <| "name",
(e <| "uesr").map { [$0] } ?? e <|| "users"
).map(create)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment