Sample code for 30+ languages & platforms
Delphi ActiveX Requires Chilkat v11.0.0+

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

Delphi ActiveX
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}]