JavaScript
JavaScript
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.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var arr1 = new CkJsonArray();
var arr2 = new CkJsonArray();
var s = "[{\"a\":1}, {\"b\":2}, {\"c\":3}]";
var sEmpty = "[]";
arr1.Load(s);
arr2.Load(sEmpty);
var jObj = new CkJsonObject();
arr1.ObjectAt2(1,jObj);
arr2.AddObjectCopyAt(-1,jObj);
console.log(arr2.Emit());
// output is: [{"b":2}]