Skip to content

Instantly share code, notes, and snippets.

@eicnix
Created July 7, 2015 18:28
Show Gist options
  • Save eicnix/8b1dbaf54a0257b011df to your computer and use it in GitHub Desktop.
Save eicnix/8b1dbaf54a0257b011df to your computer and use it in GitHub Desktop.
Parsing nullable types with argonaut
import argonaut._
import Argonaut._
object Main extends App{
val json = "{ \"name\": \"Peter\", \"score\": null}"
case class Player(name: String, score: Option[String])
implicit def PlayerCodecJson: CodecJson[Player] =
casecodec2(Player.apply, Player.unapply)("name", "score")
println(Parse.decode[Player](json))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment