Sample code for 30+ languages & platforms
B4X

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

B4X
'  Create JSON with members of different data types.
Dim json As ChilkatJsonObject
json.Initialize

json.UpdateInt("a", 123)
json.UpdateBool("b", True)
json.UpdateNull("c")

json.EmitCompact = False
Log(json.Emit)

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

Dim a As String = json.StringOf("a")
Log(a)

Dim b As String = json.StringOf("b")
Log(b)

Dim c As String = json.StringOf("c")
Log(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
Dim ival As Int = json.IntOf("a")
Dim bval As Boolean = json.BoolOf("b")
Dim hasNull As Boolean = json.IsNullOf("c")