thomaserlang / delphi-json

JSON parser for Delphi.
83 stars 32 forks source link

Access Violation on Parse. #10

Closed AdriaanBoshoff closed 6 years ago

AdriaanBoshoff commented 6 years ago

Hi, Is there a reason that this might cause an access violation? Note: I have changed the object names from TJSON to TdJSON to avoid conflicts with json writers.

function IsValidLicense(const aLicense: string): Boolean;
var
  http: TIdHTTP;
  jdata: TdJSON;
begin
  http := TIdHTTP.Create(nil);
  try
    jdata.Parse(http.Get('http://qs.quantumsoftware.co.za:7777/rsm/license?key=' + aLicense));
    try
      Result := jdata['valid'].AsBoolean;
    finally
      jdata.Free;
    end;
  finally
    http.Free;
  end;
end;

This is the json response:

{
  "valid": true,
  "message": "Product key is valid!"
}
tobya commented 6 years ago

It looks to me like jdata doesnt exist

AdriaanBoshoff commented 6 years ago

omw I'm stupid. I only see now I'm never actually creating it. This is what happens when you code at 3am. Thanks for the hint hahaha.