summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShankarShastri <shastri.shankar9@gmail.com>2018-03-20 09:48:37 +0530
committerGitHub <noreply@github.com>2018-03-20 09:48:37 +0530
commit2187d75cf69be932154033c5905a5b771cc4ed59 (patch)
treea524ba1a1c7a3b122ad8db28008f96805c2a85b0
parentf0c46b05709889cfddf1650df49287c6984315ac (diff)
downloadspray-json-2187d75cf69be932154033c5905a5b771cc4ed59.tar.gz
spray-json-2187d75cf69be932154033c5905a5b771cc4ed59.tar.bz2
spray-json-2187d75cf69be932154033c5905a5b771cc4ed59.zip
Updated to use new instead of case-class
Updated to use new instead of case-class
-rw-r--r--README.markdown6
1 files changed, 3 insertions, 3 deletions
diff --git a/README.markdown b/README.markdown
index 6165839..7c8da91 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
-case class Color(val name: String, val red: Int, val green: Int, val blue: Int)
+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))) =>
- Color(name, red.toInt, green.toInt, blue.toInt)
+ new Color(name, red.toInt, green.toInt, blue.toInt)
case _ => deserializationError("Color expected")
}
}
@@ -188,7 +188,7 @@ object MyJsonProtocol extends DefaultJsonProtocol {
import MyJsonProtocol._
-val json = Color("CadetBlue", 95, 158, 160).toJson
+val json = new Color("CadetBlue", 95, 158, 160).toJson
val color = json.convertTo[Color]
```