Created
April 14, 2018 12:06
-
-
Save anuragsrivastava06/23b9475d86e4b9ad0da2a6207551bdf0 to your computer and use it in GitHub Desktop.
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
final case class Person(name: String, email: String) | |
object JsonWriterInstances { | |
implicit val stringWriter: JsonWriter[String] = | |
new JsonWriter[String] { | |
def write(value: String): Json = JsString(value) | |
} | |
implicit val personWriter: JsonWriter[Person] = | |
new JsonWriter[Person] { | |
def write(value: Person): Json = | |
JsObject(Map( | |
"name" -> JsString(value.name), | |
"email" -> JsString(value.email) | |
)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment