Sample code for 30+ languages & platforms
Classic ASP

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

Chilkat Classic ASP Downloads

Classic ASP
<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 object named "addr"
set jObj = Server.CreateObject("Chilkat.JsonObject")
success = json.AppendObject2("addr",jObj)

Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>"
' Expected output is:   {"name":"John","marbles":100,"addr":{}}

' Add members to the object.
success = jObj.AppendString("street","1200 Elm St.")
success = jObj.AppendString("city","Springfield")
success = jObj.AppendInt("zip",60606)

Response.Write "<pre>" & Server.HTMLEncode( json.Emit()) & "</pre>"
' Expected output is:  {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}

%>
</body>
</html>