Delphi ActiveX
Delphi ActiveX
Copy JSON Object from one JSON Array to Another
See more JSON Examples
Demonstrates how to copy an object in a JSON array to another JSON array.Chilkat Delphi ActiveX Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
arr1: TChilkatJsonArray;
arr2: TChilkatJsonArray;
s: WideString;
sEmpty: WideString;
jObj: TChilkatJsonObject;
begin
arr1 := TChilkatJsonArray.Create(Self);
arr2 := TChilkatJsonArray.Create(Self);
s := '[{"a":1}, {"b":2}, {"c":3}]';
sEmpty := '[]';
arr1.Load(s);
arr2.Load(sEmpty);
jObj := TChilkatJsonObject.Create(Self);
arr1.ObjectAt2(1,jObj.ControlInterface);
arr2.AddObjectCopyAt(-1,jObj.ControlInterface);
Memo1.Lines.Add(arr2.Emit());
// output is: [{"b":2}]
end;