diff options
author | ShankarShastri <shastri.shankar9@gmail.com> | 2018-03-20 09:33:50 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-20 09:33:50 +0530 |
commit | f0c46b05709889cfddf1650df49287c6984315ac (patch) | |
tree | 846eac15833a4e23baa4d5bbf6c25ba1d7b14de5 | |
parent | 216fae2a934719179a91d60de0a251dbe84682ea (diff) | |
download | spray-json-f0c46b05709889cfddf1650df49287c6984315ac.tar.gz spray-json-f0c46b05709889cfddf1650df49287c6984315ac.tar.bz2 spray-json-f0c46b05709889cfddf1650df49287c6984315ac.zip |
Correct Example
Correct Example In Providing JsonFormats for other Types.
-rw-r--r-- | README.markdown | 4 |
1 files 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") } } |