You are not logged in.
I have a customer who is using Delphi 6 and needs to use JSON parsing.
(Yes it is very old and I don't know why he have to use this version)
The following code will display a message dialog showing "ABC" if run on Delphi 7.
If run in Delphi 6 I will only get "Invalid variant type conversion" exception.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SynCommons, StdCtrls;
...
procedure TForm1.Button1Click(Sender: TObject);
var
Test: variant;
begin
TDocVariant.New(Test);
try
Test.param := 'ABC';
// If breaking and inspecting Test here it will be '{"PARAM":"ABC"}' in Delphi 6 and '{"param":"ABC"}' in Delphi 7
ShowMessage(Test.param); // Exception here
except
on E: Exception do ShowMessage(E.Message);
end;
end;
Offline
Thanks, it works great!
But maybe I'll try to convince them to use a newer Delphi version instead :-)
Offline