ahausladen / JsonDataObjects

JSON parser for Delphi 2009 and newer
MIT License
414 stars 159 forks source link

Parsing fails for some Int64 values #2

Closed te1 closed 9 years ago

te1 commented 9 years ago

Parsing seems to fail for all Int64 values x where MaxInt < x <= 2*MaxInt + 1. Other values work fine. The problem seems to be that FLook.HI = 0 and therefore FLook.I is used instead of FLook.L. Unfortunately I don't know how to fix it so I can't provide you with a pull request.

var
  lInput: String;
  lInt64: Int64;
  lJsonObject: TJsonObject;
begin
  lInt64 := 2 * Int64(MaxInt);
  lInput := Format('{ "num": %d }', [lInt64]);

  lJsonObject := TJsonObject.Parse(lInput) as TJsonObject;
  try
    Writeln(lInput); // { "num": 4294967294 }
    Writeln(lInt64); // 4294967294
    Writeln(lJsonObject.L['num']); // -2
  finally
    lJsonObject.Free;
  end;
end;

This is Delphi XE5.

ahausladen commented 9 years ago

Thanks for the bug report. This is fixed in 6796437dcbfdb227b1b40e04b1161499cb239953

te1 commented 9 years ago

Thank you for the very quick fix :+1: