(Visual FoxPro) Using JSON StringOf with Non-String Members
If a JSON member is a boolean, integer, or null, using StringOf will return its string representation.
LOCAL loJson
LOCAL a
LOCAL b
LOCAL c
LOCAL lnIval
LOCAL lnBval
LOCAL lnHasNull
* Create JSON with members of different data types.
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateInt("a",123)
loJson.UpdateBool("b",1)
loJson.UpdateNull("c")
loJson.EmitCompact = 0
? 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")
lnBval = loJson.BoolOf("b")
lnHasNull = loJson.IsNullOf("c")
RELEASE loJson
|