[Json-rpc-java] Severe problem with long integers

Ilya Boyandin Ilya.Boyandin at fh-joanneum.at
Tue Apr 17 20:38:21 SGT 2007


Hello Michael,

thanks for your quick answer. Ok, I see your point, it could really 
potentially break someone's code.

Then maybe you will add a property to JSONSerializer, something like 
setQuoteLongValues(boolean) which is false by default, but provided with 
a commentary explaining the reasons for setting it to true?

Another possibility would be to make new implementations for 
PrimitiveSerializer and NumberSerializer whoose marshall methods return 
Strings instead of objects for longs and doubles. What do you think 
about it?

Best regards
Ilya

Michael Clark wrote:
> Perhaps if (abs(num) >= 2^53) then return string; ??
>
> Although code could subtlety break when it tries to do any math
> operators of these "numbers" and + will suddenly become string
> concatenation.
>
> Not completely convinced it is the best idea (as you could just return
> String from your Java code if you need this behaviour).
>
> I would be more inclined to do if (type is Long and abs(num) >= 2^53)
> then throw IntegerOverflowException
>   



More information about the Json-rpc-java mailing list