Sample code for 30+ languages & platforms
AutoIt

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

AutoIt
; Create JSON with members of different data types.
$oJson = ObjCreate("Chilkat.JsonObject")

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

$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)

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

Local $sA = $oJson.StringOf("a")
ConsoleWrite($sA & @CRLF)

Local $sB = $oJson.StringOf("b")
ConsoleWrite($sB & @CRLF)

Local $sC = $oJson.StringOf("c")
ConsoleWrite($sC & @CRLF)

; 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
Local $ival = $oJson.IntOf("a")
Local $bval = $oJson.BoolOf("b")
Local $bHasNull = $oJson.IsNullOf("c")