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

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

Chilkat B4X Downloads

B4X
Dim json As ChilkatJsonObject
json.Initialize
json.Load("{ " & Chr(34) & "name" & Chr(34) & ": " & Chr(34) & "John" & Chr(34) & ", " & Chr(34) & "marbles" & Chr(34) & ": 100 }")

'  Append an empty object named "addr"
Dim jObj As ChilkatJsonObject
jObj.Initialize
json.AppendObject2("addr", jObj)

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

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

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