You are not logged in.
Pages: 1
As TObjectList is not a TPersistentClass it cannot be registered for JSON via Rtti.RegisterClass and TJSONSerializer.RegisterClassForJSON is not available anymore.
How can I register it as I use it extensively in mormot1 code migrated to mormot2
Thanks
AntonE
Offline
I'm not sure I understood you correctly, but this works without any registration:
var
item: TItem; // TItem = class(TObject)
list: TObjectList;
begin
list := TObjectList.Create;
try
list.Add(TItem.Create('value1'));
list.Add(TItem.Create('value2'));
ObjectToJsonFile(list, '_listData.json');
finally
list.Free;
end;
With best regards
Thomas
Offline
I have TJSONSerializer.RegisterClassForJSON(TObjectList) on Client app (XE4/mormot1) but had to comment that line out on server (D11/mormot2) as described in OP.
I pass the objectlist via Intertfaced based service method,e.g.
function CalList(var Lst:TObjectList):Boolean;
Regards
AntonE
Last edited by AntonE (2022-05-07 15:19:11)
Offline
Pages: 1