Sample code for 30+ languages & platforms
Xbase++ 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 Xbase++ Downloads

Xbase++
LOCAL oArr1
LOCAL oArr2
LOCAL s
LOCAL cSEmpty
LOCAL oJObj

oArr1 := CreateObject("Chilkat.JsonArray")
oArr2 := CreateObject("Chilkat.JsonArray")

s := '[{"a":1}, {"b":2}, {"c":3}]'
cSEmpty := "[]"

oArr1:Load(s)
oArr2:Load(cSEmpty)

oJObj := CreateObject("Chilkat.JsonObject")
oArr1:ObjectAt2(1, oJObj)

oArr2:AddObjectCopyAt(-1, oJObj)

? oArr2:Emit()

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

oArr1:destroy()
oArr2:destroy()
oJObj:destroy()