Closed GoogleCodeExporter closed 9 years ago
This problem occurs because we require + or - after the "e" sign. So,
1.234567899E+8
will work fine.
Original comment by inder123
on 4 Mar 2009 at 6:52
But Gson itself produce such json without + or - after e and it is a valid
number
format. Following code produce the same Exception (gson1.3 Rev. 389):
public class FindIssue {
public double largeNumber;
public static void main(String[] args) {
Gson gson = new Gson();
FindIssue fi=new FindIssue();
fi.largeNumber=1234567899;
String json=gson.toJson(fi);
System.out.println("json: "+json);
FindIssue f=gson.fromJson(json, FindIssue.class);
System.out.println(f.largeNumber);
}
}
Original comment by J.Berin...@gmail.com
on 5 Mar 2009 at 7:15
[deleted comment]
J.Beringer is right, Gson itself omits the "+" sign after E when emitting
numbers,
but then throws an exception when trying to parse the string it generated.
According to the spec at json.org, the sign after E is not required. All of
these
formats should be recognized:
E+25
E-25
E25
e+25
e-25
e25
inder123, can you remove the sign requirement from your grammar?
Original comment by alexande...@gmail.com
on 5 Mar 2009 at 9:28
[deleted comment]
Fixed in r390. Updated Gson grammar to support floating point numbers without
the +/-
sign after E. This was a bit tricky since E8 matches an identifier as well, and
that
was the source of the earlier bug. Added tests in PrimitiveTest to verify this
behavior.
Original comment by inder123
on 5 Mar 2009 at 11:07
Original comment by inder123
on 27 Mar 2009 at 7:39
Original issue reported on code.google.com by
J.Berin...@gmail.com
on 20 Jan 2009 at 10:07