Open GoogleCodeExporter opened 9 years ago
Great bug. The distilled form looks like this:
public void testDeserialize() {
String number = "1.020204000000e+12";
new Gson().fromJson(number, Long.class); // works
new Gson().fromJson(new JsonPrimitive(number), Long.class); // fails
}
The underlying problem is that we have two different ways to convert strings to
longs. In JsonPrimitive we truncate the high order bits. This program prints
two '1' characters:
System.out.println(new JsonPrimitive("1").getAsNumber().longValue());
System.out.println(new JsonPrimitive("18446744073709551617").getAsNumber().longValue());
We should be doing something more robust throughout JsonPrimitive.
Original comment by limpbizkit
on 30 Jun 2012 at 3:06
Original comment by limpbizkit
on 30 Jun 2012 at 3:07
Thanks for the distilled form and explanations. I'm looking forward for your
fix, because this is a showstopper for us and prevents from upgrading from
version 1.x to 2.x
Original comment by jenshadl...@googlemail.com
on 1 Jul 2012 at 12:02
Issue 462 has been merged into this issue.
Original comment by limpbizkit
on 2 Sep 2012 at 9:39
Original issue reported on code.google.com by
jenshadl...@googlemail.com
on 22 Jun 2012 at 10:11Attachments: