diff options
author | Steffen Fritzsche <steffen.fritzsche@uni-ulm.de> | 2011-10-11 18:33:59 +0200 |
---|---|---|
committer | Steffen Fritzsche <steffen.fritzsche@uni-ulm.de> | 2011-10-11 18:33:59 +0200 |
commit | fe8fca4e69a21b5a795a000d4bd27026a06aa6a0 (patch) | |
tree | ff1f4ab000c68f18c8b63cbba19ca8f019b3a600 /src/main/scala/cc/spray/json/BasicFormats.scala | |
parent | 211e72c22cf620c12835738b2a62c50867331fa6 (diff) | |
download | spray-json-fe8fca4e69a21b5a795a000d4bd27026a06aa6a0.tar.gz spray-json-fe8fca4e69a21b5a795a000d4bd27026a06aa6a0.tar.bz2 spray-json-fe8fca4e69a21b5a795a000d4bd27026a06aa6a0.zip |
Implemented deserialization support (Issue #8)
Diffstat (limited to 'src/main/scala/cc/spray/json/BasicFormats.scala')
-rw-r--r-- | src/main/scala/cc/spray/json/BasicFormats.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/scala/cc/spray/json/BasicFormats.scala b/src/main/scala/cc/spray/json/BasicFormats.scala index e16b4ca..32ae91e 100644 --- a/src/main/scala/cc/spray/json/BasicFormats.scala +++ b/src/main/scala/cc/spray/json/BasicFormats.scala @@ -42,6 +42,7 @@ trait BasicFormats { def write(x: Float) = JsNumber(x) def read(value: JsValue) = value match { case JsNumber(x) => x.floatValue + case JsNull => Float.NaN case _ => throw new DeserializationException("Float expected") } } @@ -50,6 +51,7 @@ trait BasicFormats { def write(x: Double) = JsNumber(x) def read(value: JsValue) = value match { case JsNumber(x) => x.doubleValue + case JsNull => Double.NaN case _ => throw new DeserializationException("Double expected") } } @@ -124,4 +126,4 @@ trait BasicFormats { } } -}
\ No newline at end of file +} |