#1 Re: mORMot 1 » TDocVariant JSON parsing, Invalid variant type conversion in Delphi 6 » 2018-12-11 16:44:31

Thanks, it works great!

But maybe I'll try to convince them to use a newer Delphi version instead :-)

#2 mORMot 1 » TDocVariant JSON parsing, Invalid variant type conversion in Delphi 6 » 2018-12-11 12:40:11

magnushc
Replies: 3

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;

Board footer

Powered by FluxBB