(VBScript) Example: JsonObject.NewArrayOf method
Demonstrates the NewArrayOf method.Note: This example requires Chilkat v11.4.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)
success = 0
big_cats = "[""lion"",""tiger"",""leopard"",""jaguar"",""cheetah"",""snow leopard"",""clouded leopard"",""cougar"",""puma"",""panther""]"
set json = CreateObject("Chilkat.JsonObject")
success = json.UpdateString("test","abc")
success = json.NewArrayOf("big_cats",big_cats)
If (success = 0) Then
outFile.WriteLine(json.LastErrorText)
WScript.Quit
End If
json.EmitCompact = 0
outFile.WriteLine(json.Emit())
' Result:
' {
' "test": "abc",
' "big_cats": [
' "lion",
' "tiger",
' "leopard",
' "jaguar",
' "cheetah",
' "snow leopard",
' "clouded leopard",
' "cougar",
' "puma",
' "panther"
' ]
' }
outFile.Close
|