Sample code for 30+ languages & platforms
C#

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 C# Downloads

C#
Chilkat.JsonArray arr1 = new Chilkat.JsonArray();
Chilkat.JsonArray arr2 = new Chilkat.JsonArray();

string s = "[{\"a\":1}, {\"b\":2}, {\"c\":3}]";
string sEmpty = "[]";

arr1.Load(s);
arr2.Load(sEmpty);

Chilkat.JsonObject jObj = new Chilkat.JsonObject();
arr1.ObjectAt2(1,jObj);

arr2.AddObjectCopyAt(-1,jObj);

Debug.WriteLine(arr2.Emit());

// output is:   [{"b":2}]