Sample code for 30+ languages & platforms
VBScript Requires Chilkat v11.0.0+

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

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 json = CreateObject("Chilkat.JsonObject")
success = json.Load("{ ""name"": ""John"", ""marbles"": 100 }")

'  Append an empty object named "addr"
set jObj = CreateObject("Chilkat.JsonObject")
success = json.AppendObject2("addr",jObj)

outFile.WriteLine(json.Emit())
'  Expected output is:   {"name":"John","marbles":100,"addr":{}}

'  Add members to the object.
success = jObj.AppendString("street","1200 Elm St.")
success = jObj.AppendString("city","Springfield")
success = jObj.AppendInt("zip",60606)

outFile.WriteLine(json.Emit())
'  Expected output is:  {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}

outFile.Close