(VBScript) JSON AppendArray Example
Demonstrates the AppendArray function.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = CreateObject("Chilkat.JsonObject")
success = json.Load("{ ""name"": ""John"", ""marbles"": 100 }")
' Append an empty array named "xyz"
' jarr is a Chilkat.JsonArray
Set jarr = json.AppendArray("xyz")
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
|