Json Serializer raises exception with TList< TObject descendant >

Hello..

  TTest = class
  private
    FId: integer;
  end;
  
  TMain = class
  private
    FDI: TList<TTest>;
  end;

and try to serialize as follow

  var X := TMain.Create;
  X.FDI := TList<TTest>.Create;
  
  VAR A := TTest.Create;
  A.FId := 1;
  X.FDI.Add(A);

  var ser :=  TJson.Serialize(X);

then I will get an Exception: "'Could not find JSON converter for type "Pointer"'
the problem the class TTest. If i change the data type of list to TList .. then the seralization is successful. By the same way if I change TList for a simple Array, also is successful.

It works fine here. Can you please send a project reproducing the issue?

Archive.zip (6.4 KB)

Delphi doesn't generate correct RTTI to classes declared in the .dpr file.
Please try to move TTest and TMain classes to a separated unit.

Yes!! I forgot that! I will try again, must be it. Sorry for the inconvenience.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.