|
|
(Xojo Plugin) Using JSON StringOf with Non-String Members
If a JSON member is a boolean, integer, or null, using StringOf will return its string representation.
// Create JSON with members of different data types.
Dim json As New Chilkat.JsonObject
Dim success As Boolean
success = json.UpdateInt("a",123)
success = json.UpdateBool("b",True)
success = json.UpdateNull("c")
json.EmitCompact = False
System.DebugLog(json.Emit())
// Resulting JSON:
// {
// "a": 123,
// "b": true,
// "c": null
// }
Dim a As String
a = json.StringOf("a")
System.DebugLog(a)
Dim b As String
b = json.StringOf("b")
System.DebugLog(b)
Dim c As String
c = json.StringOf("c")
System.DebugLog(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 Int32
ival = json.IntOf("a")
Dim bval As Boolean
bval = json.BoolOf("b")
Dim hasNull As Boolean
hasNull = json.IsNullOf("c")
|