JsonDataObjects icon indicating copy to clipboard operation
JsonDataObjects copied to clipboard

Best practice for improve performance on write

Open cesco69 opened this issue 5 years ago • 0 comments

From my benchmark JsonDataObjects is the fastest lib for read write json in delphi, It's awersome! but is poor in documentation.

I'm searching for examples for writing large json (over 50000 nodes, less or more 90 MB) with the best performance.

Eg. is better writing the objects with the full path:

var
  Obj: TJsonObject;
  i: integer;
begin
  Obj := TJsonObject.Create;
  for i := 0 to 50000 do begin
     Obj['foo']['bar']['baz'].A['array'].Add(i);
  end;
  Obj.Free;
end;

or write by caching the parent, eg.:

var
  Obj: TJsonObject;
  aArray:  TJsonArray;
  i: integer;
begin
  Obj := TJsonObject.Create;
  aArray := Obj['foo']['bar']['baz'].A['array'];
  for i := 0 to 50000 do begin
     aArray.Add(i);
  end;
  Obj.Free;
end;

other trick and tips are welcome!

cesco69 avatar May 15 '19 07:05 cesco69