(VB.NET) 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
json.UpdateInt("a",123)
json.UpdateBool("b",True)
json.UpdateNull("c")
json.EmitCompact = False
Debug.WriteLine(json.Emit())
' Resulting JSON:
' {
' "a": 123,
' "b": true,
' "c": null
' }
Dim a As String = json.StringOf("a")
Debug.WriteLine(a)
Dim b As String = json.StringOf("b")
Debug.WriteLine(b)
Dim c As String = json.StringOf("c")
Debug.WriteLine(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 Integer = json.IntOf("a")
Dim bval As Boolean = json.BoolOf("b")
Dim hasNull As Boolean = json.IsNullOf("c")
|