(PowerBuilder) Append New Item to JSON Array
Demonstrates the notations that can be used in a JSON array index to append to the end of an array.
integer li_rc
oleobject loo_Json
// Starting in Chilkat v9.5.0.77, the following notations are possible to specify that the value
// should be appended to the end of the array. (In other words, if the array currenty has N elements, then "-1", "", or "*"
// indicate an index of N+1.
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.UpdateInt("lanes[-1]",0)
loo_Json.UpdateInt("lanes[]",1)
loo_Json.UpdateInt("lanes[*]",2)
loo_Json.UpdateInt("lanes[-1]",3)
Write-Debug loo_Json.Emit()
// Output is: {"lanes":[0,1,2,3]}
destroy loo_Json
|