(PowerBuilder) JSON AppendArray Example
Demonstrates the AppendArray function.
integer li_rc
oleobject loo_Json
oleobject loo_Jarr
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
destroy loo_Json
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Json.Load("{ ~"name~": ~"John~", ~"marbles~": 100 }")
// Append an empty array named "xyz"
loo_Jarr = loo_Json.AppendArray("xyz")
Write-Debug loo_Json.Emit()
// Expected output is: {"name":"John","marbles":100,"xyz":[]}
// Add elements to the array.
loo_Jarr.AddStringAt(-1,"hello")
loo_Jarr.AddIntAt(-1,256)
Write-Debug loo_Json.Emit()
// Expected output is: {"name":"John","marbles":100,"xyz":["hello",256]}
destroy loo_Jarr
destroy loo_Json
|