Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
// Create JSON with members of different data types.
loJson = createobject("CkJsonObject")

loJson.UpdateInt("a",123)
loJson.UpdateBool("b",.T.)
loJson.UpdateNull("c")

loJson.EmitCompact = .F.
? loJson.Emit()

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

a = loJson.StringOf("a")
? a

b = loJson.StringOf("b")
? b

c = loJson.StringOf("c")
? 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
lnIval = loJson.IntOf("a")
llBval = loJson.BoolOf("b")
llHasNull = loJson.IsNullOf("c")


release loJson