Sample code for 30+ languages & platforms
VBScript

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 VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

set arr1 = CreateObject("Chilkat.JsonArray")
set arr2 = CreateObject("Chilkat.JsonArray")

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

success = arr1.Load(s)
success = arr2.Load(sEmpty)

set jObj = CreateObject("Chilkat.JsonObject")
success = arr1.ObjectAt2(1,jObj)

success = arr2.AddObjectCopyAt(-1,jObj)

outFile.WriteLine(arr2.Emit())

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

outFile.Close