Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
' Create JSON with members of different data types.
Dim json As New ChilkatJsonObject

success = json.UpdateInt("a",123)
success = json.UpdateBool("b",1)
success = json.UpdateNull("c")

json.EmitCompact = 0
Debug.Print json.Emit()

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

Dim a As String
a = json.StringOf("a")
Debug.Print a

Dim b As String
b = json.StringOf("b")
Debug.Print b

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