(Classic ASP) JSON AppendArray2 Example
Demonstrates the AppendArray2 function. Note: This example requires Chilkat v11.0.0 or greater.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.Load("{ ""name"": ""John"", ""marbles"": 100 }")
' Append an empty array named "xyz"
set jarr = Server.CreateObject("Chilkat.JsonArray")
success = json.AppendArray2("xyz",jarr)
Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>"
' Expected output is: {"name":"John","marbles":100,"xyz":[]}
' Add elements to the array.
success = jarr.AddStringAt(-1,"hello")
success = jarr.AddIntAt(-1,256)
Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>"
' Expected output is: {"name":"John","marbles":100,"xyz":["hello",256]}
%>
</body>
</html>
|