(PowerBuilder) JSON AppendArray2 Example
Demonstrates the AppendArray2 function. Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc
oleobject loo_Json
oleobject loo_Jarr
loo_Json = create oleobject
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 = create oleobject
li_rc = loo_Jarr.ConnectToNewObject("Chilkat.JsonArray")
loo_Json.AppendArray2("xyz",loo_Jarr)
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_Json
destroy loo_Jarr
|