Go
Go
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 Go Downloads
arr1 := chilkat.NewJsonArray()
arr2 := chilkat.NewJsonArray()
s := "[{\"a\":1}, {\"b\":2}, {\"c\":3}]"
sEmpty := "[]"
arr1.Load(s)
arr2.Load(sEmpty)
jObj := chilkat.NewJsonObject()
arr1.ObjectAt2(1,jObj)
arr2.AddObjectCopyAt(-1,jObj)
fmt.Println(*arr2.Emit())
// output is: [{"b":2}]
arr1.DisposeJsonArray()
arr2.DisposeJsonArray()
jObj.DisposeJsonObject()