Closed hafedh-trimeche closed 2 years ago
Hi, Thanks for your suggestion. Could you show a simple example simulating McJSON as if it had this feature? Also, does the current version of Tostring() have any performance issues? Regards, Marcelo.
Hi,
For a large JSON Document, using string concatenation would have impact on performance because of string memory allocation.
String Buffering would be implemented as:
procedure TMcJsonItem.InternalToString(Stream:TStringStream;aHuman,aIndent:string;JsonItem:TMcJsonItem);
begin
...
for i := 0 to len do
begin
Stream.WriteString(JsonItem...);
...
end;
...
end;
function TMcJsonItem.Stringify(aHuman:Boolean=False;const aIndent:string=''):string;
var
Stream : TStringStream;
begin
Stream := TStringStream.Create;
InternalToString(Stream,aHuman,aIndent,Self);
Result := Stream.DataString;
Stream.Free;
end;
Best regards.
Hi Hafedh,
Nice suggestion!
I'll try it, just let me finish an update about better Exception handling and descriptions.
Thanks,
Marcelo.
Hi Hafedh, The last commit uses TStringStream as buffer with ToString(). Thanks, Marcelo.
Hello,
Would a String Buffer, String Stream, Binary Stream... be used instead String Concatenation when invoking ToString?
Delphi has TStringBuilder Class.
Best regards.