Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

AppendArrayItems Example

Demonstrates the AppendArrayItems function.

Note: This example requires Chilkat v9.5.0.82 or above.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.JsonArray;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  jarr1: TJsonArray;
  jarr2: TJsonArray;

begin
  jarr1 := TJsonArray.Create;
  jarr1.Load('[ 1, 2, 3, 4]');

  jarr2 := TJsonArray.Create;
  jarr2.Load('[ 5, 6, 7, 8]');

  jarr1.AppendArrayItems(jarr2);

  WriteLn(jarr1.Emit());
  //  Expected output: [1,2,3,4,5,6,7,8]

  WriteLn(jarr2.Emit());
  //  Expected output: [5,6,7,8]


  jarr1.Free;
  jarr2.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.