Classic ASP
Classic ASP
Using JSON StringOf with Non-String Members
See more JSON Examples
If a JSON member is a boolean, integer, or null, usingStringOf will return its string representation.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' Create JSON with members of different data types.
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateInt("a",123)
success = json.UpdateBool("b",1)
success = json.UpdateNull("c")
json.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>"
' Resulting JSON:
' {
' "a": 123,
' "b": true,
' "c": null
' }
a = json.StringOf("a")
Response.Write "<pre>" & Server.HTMLEncode( a) & "</pre>"
b = json.StringOf("b")
Response.Write "<pre>" & Server.HTMLEncode( b) & "</pre>"
c = json.StringOf("c")
Response.Write "<pre>" & Server.HTMLEncode( c) & "</pre>"
' 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
ival = json.IntOf("a")
bval = json.BoolOf("b")
hasNull = json.IsNullOf("c")
%>
</body>
</html>