(PowerBuilder) JSON Add Large Integer or Double
Demonstrates how to add a large number (larger than what can be held in an integer), or a double/float value to a JSON document.
integer li_rc
oleobject loo_Json
integer li_Index
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
// To add a large integer, use AddNumberAt.
// (an index of -1 indicates append).
li_Index = -1
loo_Json.AddNumberAt(li_Index,"bignum","8239845689346587465826345892644873453634563456")
// Do the same for a double..
loo_Json.AddNumberAt(li_Index,"double","-153634.295")
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()
// Output:
// {
// "bignum": 8239845689346587465826345892644873453634563456,
// "double": -153634.295
// }
destroy loo_Json
|