Created
July 7, 2015 18:28
-
-
Save eicnix/8b1dbaf54a0257b011df to your computer and use it in GitHub Desktop.
Parsing nullable types with argonaut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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