Sample code for 30+ languages & platforms
Delphi DLL

Using Chilkat StringBuilder to Avoid Large Strings

See more uncategorized Examples

Some programming languages can have limitations on string lengths, or it can be inefficient to return large strings back to the application, only to be passed back into Chilkat in a subsequent method call.

For Chilkat functions that return a string where the returned string can potentially be very large, there is typically the same function with the name ending in "Sb", where the returned string is deposited into the last argument. This allows for the string remain within an object, and thus never marshalled to/from the application.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, JsonObject;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
json: HCkJsonObject;
jsonStr: PWideChar;
sb: HCkStringBuilder;

begin
success := False;

http := CkHttp_Create();
json := CkJsonObject_Create();

// This is the potentially inefficient way of getting JSON from a URL and loading it into a Chilkat JsonObject.
// It gets the string directly..
jsonStr := CkHttp__quickGetStr(http,'https://www.chilkatsoft.com/helloWorld.json');
success := CkJsonObject_Load(json,jsonStr);

// This is the more efficient method if the JSON is potentially large
sb := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://www.chilkatsoft.com/helloWorld.json',sb);
success := CkJsonObject_LoadSb(json,sb);

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sb);

end;