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

JSON Append String Array

See more JSON Examples

Demonstrates how to append an array of strings from a string table object.

Note: This example uses the AppendStringTable method, which was introduced in Chilkat v9.5.0.67

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.JsonObject,
  Chilkat.StringTable;

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

procedure RunDemo;
var
  json: TJsonObject;
  st: TStringTable;

begin
  json := TJsonObject.Create;
  json.EmitCompact := False;

  json.AppendString('abc','123');

  st := TStringTable.Create;
  st.Append('a');
  st.Append('b');
  st.Append('c');
  st.Append('d');

  json.AppendStringArray('strArray',st);

  WriteLn(json.Emit());

  //  Output:

  //  	{
  //  	  "abc": "123",
  //  	  "strArray": [
  //  	    "a",
  //  	    "b",
  //  	    "c",
  //  	    "d"
  //  	  ]
  //  	}


  json.Free;
  st.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.