From f0c46b05709889cfddf1650df49287c6984315ac Mon Sep 17 00:00:00 2001 From: ShankarShastri Date: Tue, 20 Mar 2018 09:33:50 +0530 Subject: Correct Example Correct Example In Providing JsonFormats for other Types. --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 30ca8ed..6165839 100644 --- a/README.markdown +++ b/README.markdown @@ -171,7 +171,7 @@ Of course you can also supply (de)serialization logic for types that aren't case Here is one way to do it: ```scala -class Color(val name: String, val red: Int, val green: Int, val blue: Int) +case class Color(val name: String, val red: Int, val green: Int, val blue: Int) object MyJsonProtocol extends DefaultJsonProtocol { implicit object ColorJsonFormat extends RootJsonFormat[Color] { @@ -180,7 +180,7 @@ object MyJsonProtocol extends DefaultJsonProtocol { def read(value: JsValue) = value match { case JsArray(Vector(JsString(name), JsNumber(red), JsNumber(green), JsNumber(blue))) => - new Color(name, red.toInt, green.toInt, blue.toInt) + Color(name, red.toInt, green.toInt, blue.toInt) case _ => deserializationError("Color expected") } } -- cgit v1.2.3