Node.js
Node.js
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 Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var arr1 = new chilkat.JsonArray();
var arr2 = new chilkat.JsonArray();
var s = "[{\"a\":1}, {\"b\":2}, {\"c\":3}]";
var sEmpty = "[]";
arr1.Load(s);
arr2.Load(sEmpty);
var jObj = new chilkat.JsonObject();
arr1.ObjectAt2(1,jObj);
arr2.AddObjectCopyAt(-1,jObj);
console.log(arr2.Emit());
// output is: [{"b":2}]
}
chilkatExample();