(PowerBuilder) JSON AppendObject Example
Demonstrates the AppendObject function.
integer li_rc
oleobject loo_Json
oleobject loo_JObj
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 object named "addr"
loo_JObj = loo_Json.AppendObject("addr")
Write-Debug loo_Json.Emit()
// Expected output is: {"name":"John","marbles":100,"addr":{}}
// Add members to the object.
loo_JObj.AppendString("street","1200 Elm St.")
loo_JObj.AppendString("city","Springfield")
loo_JObj.AppendInt("zip",60606)
Write-Debug loo_Json.Emit()
// Expected output is: {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}
destroy loo_JObj
destroy loo_Json
|