hjson-java icon indicating copy to clipboard operation
hjson-java copied to clipboard

Got wrong number when serialize a long number.

Open FalconIA opened this issue 8 years ago • 2 comments

Got wrong number when serialize a long number.

Here is a example:

String in = "{ \"id\" : 8093873769532439696 }";
String out = JsonValue.readHjson(in).toString(Stringify.HJSON)

Got

{
  id: 8093873769532439552
}

FalconIA avatar Jan 26 '18 09:01 FalconIA

8093873769532439696 is too large for the double type.

If you run this in Java you will see a similar result:

double d=Double.parseDouble("8093873769532439696");

laktak avatar Feb 08 '18 22:02 laktak

It's the long type, not the double type. I do not think that JSON should be limited to double type as javascript.

Actually, Jackson2 can recognize this value correctly.

FalconIA avatar Feb 09 '18 08:02 FalconIA