Sample code for 30+ languages & platforms
PowerBuilder

Using JSON StringOf with Non-String Members

See more JSON Examples

If a JSON member is a boolean, integer, or null, using StringOf will return its string representation.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Json
string a
string b
string c
integer li_Ival
integer li_Bval
integer li_HasNull

// Create JSON with members of different data types.
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.UpdateInt("a",123)
loo_Json.UpdateBool("b",1)
loo_Json.UpdateNull("c")

loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()

// Resulting JSON:
// {
//   "a": 123,
//   "b": true,
//   "c": null
// }

a = loo_Json.StringOf("a")
Write-Debug a

b = loo_Json.StringOf("b")
Write-Debug b

c = loo_Json.StringOf("c")
Write-Debug c

// Output

// 123
// true
// null

// If you want to get the integer, boolean, or null value
// you need to use the methods matching the data type
li_Ival = loo_Json.IntOf("a")
li_Bval = loo_Json.BoolOf("b")
li_HasNull = loo_Json.IsNullOf("c")


destroy loo_Json