(PowerBuilder) JSON Array AddObjectCopyAt Example
Demonstrates the AddObjectCopyAt function.
Note: This example requires Chilkat v9.5.0.82 or above.
integer li_rc
oleobject loo_Jarr
oleobject loo_Json
loo_Jarr = create oleobject
// Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
li_rc = loo_Jarr.ConnectToNewObject("Chilkat.JsonArray")
if li_rc < 0 then
destroy loo_Jarr
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Jarr.Load("[ 1, 2, 3, 4]")
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.Load("{~"street~":~"1200 Elm St.~",~"city~":~"Springfield~",~"zip~":60606}")
// Copy the contents of json to the array at index 2, making it the 3rd item in the array.
loo_Jarr.AddObjectCopyAt(2,loo_Json)
Write-Debug loo_Jarr.Emit()
// Expected output is: [1,2,{"street":"1200 Elm St.","city":"Springfield","zip":60606},3,4]
destroy loo_Jarr
destroy loo_Json
|