Created
December 13, 2016 10:35
-
-
Save tues/c3147252904cdb8ae3f7e8ace3df27da to your computer and use it in GitHub Desktop.
Play JSON Option[String] deserializer
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
implicit object OptionalStringReads extends Reads[Option[String]] { | |
def reads(json: JsValue) = json match { | |
case JsString(s) => JsSuccess(Some(s)) | |
case JsNull => JsSuccess(None) | |
case _ => JsError("error.expected.jsstring") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment