You are not logged in.
Hello,
I try to deserialize JSON from a rest service
type
TecRmiData = class
private
FTypeId: string;
FTcdTypeId: string;
FHerstSchluessel: string;
public
property TypeId: string read FTypeId write FTypeId;
property TcdTypeId: string read FTcdTypeId write FTcdTypeId;
property HerstSchluessel: string read FHerstSchluessel
write FHerstSchluessel;
end;
type
TKbaDataResult = class(TObject)
private
FSearchKey: string;
FTooMuchResults: Boolean;
FNumberOfResults: Integer;
FNumberOfPossibleResults: Integer;
FFoundData: TArray<TecRmiData>;
public
constructor Create;
destructor Destroy; override;
property SearchKey: string read FSearchKey write FSearchKey;
property TooMuchResults: Boolean read FTooMuchResults write FTooMuchResults;
property NumberOfResults: Integer read FNumberOfResults
write FNumberOfResults;
property NumberOfPossibleResults: Integer read FNumberOfPossibleResults
write FNumberOfPossibleResults;
property FoundData: TArray<TecRmiData> read FFoundData;
end;
Like this:
t := TKbaDataResult.Create;
valid := ObjectLoadJson(t, StringToUtf8(restRequest.Response.JSONText));
Valid is true but the object isnt populated with any data.
Offline
Valid is true but the object isnt populated with any data.
Only "published" properties are serialized. If you want to serialize other properties, you must register your own functions with TRttiJson.RegisterCustomSerializer().
With best regards
Thomas
Offline
Thanks! My problem is that with 500 child objects in the list, the whole process lasts 10 seconds for deserialisation. Is there a way to speed it up?
Offline
My problem is that with 500 child objects in the list, the whole process lasts 10 seconds for deserialisation. Is there a way to speed it up?
Something else is wrong. In this article you will find some benchmark values for comparison. The time for 500 objects should only be a few milliseconds.
With best regards
Thomas
Last edited by tbo (2024-01-10 16:17:38)
Offline
liam1983 wrote:My problem is that with 500 child objects in the list, the whole process lasts 10 seconds for deserialisation. Is there a way to speed it up?
Something else is wrong. In this article you will find some benchmark values for comparison. The time for 500 objects should only be a few milliseconds.
With best regards
Thomas
I believe this also, but how can I search for the reason? Because its not a very complex thing here.
Offline
Your class need to have its RTTI, inherit from TPersistent/TSynPersistent and have the properties "published" not public.
But since you use a dynamic array published property to store class instances, you should inherit from TSynAutoCreateFields to release all published T*ObjArray fields.
500 children in 10 seconds does not make any sense.
It should be in less than a millisecond.
Somethings is wrong in your code, I guess.
Please provide us with a https://stackoverflow.com/help/minimal- … le-example
and follow the Forum Rules https://synopse.info/forum/misc.php?action=rules : do not put the code directly in the forum.
Online