-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON serialization of infinity/NAN creates value that cannot be deserialized #33
Comments
Definitely a bug. We'll fix it right away. Thanks for reporting! On Nov 8, 2011, at 9:39 AM, Noel Welsh wrote:
|
Curious if this was ever implemented? I have a pesky Python server returning NaN and need to deal with it :) |
Daniel has made a change that converts infinities / NaN to JNothing. Which may or may not be what you want! On Aug 22, 2012, at 1:58 PM, Jeff Simpson wrote:
|
Yeah. That might work! Thanks. |
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)
The text was updated successfully, but these errors were encountered: