Facebook uses a lot of 64-bit ids. The ids we're getting from them lately are
large enough that they break the precision afforded by Number(). Since
JSONTokenizer.readNumber casts all numbers it reads into a Number(), we get the
wrong value back.
For example, Facebook will send:
[{"object_id":199999999999999991}]
Which will get converted by readNumber() into 200000000000000000.
Our fix was to change the last few lines of readNumber() to check if the
conversion to Number() was valid, and if not report the token as a string. The
change is as follows:
if ( isFinite( num ) && !isNaN( num ) )
{
if (input != String(num)) {
// invalid conversion, report as a string
return JSONToken.create(JSONTokenType.STRING, input);
} else {
return JSONToken.create( JSONTokenType.NUMBER, num );
}
}
else
{
....
Original issue reported on code.google.com by o...@sgstudios.com on 1 Dec 2011 at 2:53
Original issue reported on code.google.com by
o...@sgstudios.com
on 1 Dec 2011 at 2:53