diff options
Diffstat (limited to 'src/main/scala')
-rw-r--r-- | src/main/scala/cc/spray/json/JsValue.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/scala/cc/spray/json/JsValue.scala b/src/main/scala/cc/spray/json/JsValue.scala index 86dbb06..e4ab734 100644 --- a/src/main/scala/cc/spray/json/JsValue.scala +++ b/src/main/scala/cc/spray/json/JsValue.scala @@ -110,7 +110,11 @@ case class JsNumber(value: BigDecimal) extends JsValue object JsNumber { def apply(n: Int) = new JsNumber(BigDecimal(n)) def apply(n: Long) = new JsNumber(BigDecimal(n)) - def apply(n: Double) = new JsNumber(BigDecimal(n)) + def apply(n: Double) = n match { + case n if n.isNaN => JsNull + case n if n.isInfinity => JsNull + case _ => new JsNumber(BigDecimal(n)) + } def apply(n: BigInt) = new JsNumber(BigDecimal(n)) def apply(n: String) = new JsNumber(BigDecimal(n)) } @@ -135,4 +139,4 @@ case object JsFalse extends JsBoolean { /** * The representation for JSON null. */ -case object JsNull extends JsValue
\ No newline at end of file +case object JsNull extends JsValue |