Skip to content

Instantly share code, notes, and snippets.

@eicnix
Last active August 29, 2015 14:24
Show Gist options
  • Save eicnix/b3e8348102ad981b5919 to your computer and use it in GitHub Desktop.
Save eicnix/b3e8348102ad981b5919 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: 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