(VBScript) JSON AppendArray2 Example
Demonstrates the AppendArray2 function. Note: This example requires Chilkat v11.0.0 or greater.
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 json = CreateObject("Chilkat.JsonObject")
success = json.Load("{ ""name"": ""John"", ""marbles"": 100 }")
' Append an empty array named "xyz"
set jarr = CreateObject("Chilkat.JsonArray")
success = json.AppendArray2("xyz",jarr)
outFile.WriteLine(json.Emit())
' Expected output is: {"name":"John","marbles":100,"xyz":[]}
' Add elements to the array.
success = jarr.AddStringAt(-1,"hello")
success = jarr.AddIntAt(-1,256)
outFile.WriteLine(json.Emit())
' Expected output is: {"name":"John","marbles":100,"xyz":["hello",256]}
outFile.Close
|