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

JSON AppendArray2 Example

Demonstrates the AppendArray2 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 array named "xyz"
Dim jarr As ChilkatJsonArray
jarr.Initialize
json.AppendArray2("xyz", jarr)

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

'  Add elements to the array.
jarr.AddStringAt(-1, "hello")
jarr.AddIntAt(-1, 256)

Log(json.Emit)
'  Expected output is:  {"name":"John","marbles":100,"xyz":["hello",256]}