jdegoes/blueeyes — Issue #33: JSON serialization of infinity/NAN creates value that cannot be deserialized 
Author: noelwelsh
Created: 2011-11-08 16:39:46+00:00
State: open

Serializing a Double containing positive or negative infinity (and presumably NaN as well) creates a value that cannot then be deserialized. The JSON spec, in it's infinite wisdom, neglected to cover these cases and no common solution appears to have arisen. (It seems that browsers render these as null (/sigh) but this doesn't appear to be widely adopted.) I think BlueEyes JSON should at least be capable of deserializing all data that it serializes.

To reproduce:

val bogus = pretty( render( ("mf", Double.PositiveInfinity) ) )
val bogus = pretty( render( ("mf", Double.PositiveInfinity) ) )
bogus: String =
{
"mf":Infinity
}

scala> JsonParser.parse(bogus)
JsonParser.parse(bogus)
blueeyes.json.JsonParser$ParseException: unknown token I
Near: {
"mf":Infinity
}
at blueeyes.json.JsonParser$Parser.fail(JsonParser.scala:230)
at blueeyes.json.JsonParser$Parser.nextToken(JsonParser.scala:325)
at blueeyes.json.JsonParser$$anonfun$4.apply(JsonParser.scala:188)
at blueeyes.json.JsonParser$$anonfun$4.apply(JsonParser.scala:142)
at blueeyes.json.JsonParser$.parse(JsonParser.scala:75)
at blueeyes.json.JsonParser$.parse(JsonParser.scala:46)
at .(:17)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:680)