Skip to content

Instantly share code, notes, and snippets.

View applethepeanut's full-sized avatar

Andrew Smitherim applethepeanut

  • ATPFury Limited
  • United Kingdom
View GitHub Profile

Keybase proof

I hereby claim:

  • I am applethepeanut on github.
  • I am applethepeanut (https://keybase.io/applethepeanut) on keybase.
  • I have a public key ASCBtCCi5O3cEZWvjQBrw9XnkN9ZSCd4kFtLW7xI6rRZhAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am applethepeanut on github.
  • I am applethepeanut (https://keybase.io/applethepeanut) on keybase.
  • I have a public key ASCDgQ-KwlqCPyFM3hMNzRaj86x0Nw059BPmR3sHDI2Rdgo

To claim this, I am signing this object:

case class Blah(id: String, name: String)
object Blah {
implicit val jsonFormats = new RootJsonFormat[Blah] {
override def read(json: JsValue): Blah = {
val js = json.asJsObject
(js.fields("some_id"), js.fields("some_name")) match {
case (JsString(id), JsString(name)) => Blah(id, name)
implicit object AccountReader extends BSONDocumentReader[Account] {
override def read(bson: BSONDocument): Account = {
val account: Option[Account] = for {
id <- bson.getAs[BSONObjectID]("_id")
...
} yield new Account(id, ...)
account.getOrElse(boom)
}
}