Sample code for 30+ languages & platforms
Classic ASP

Create a JSON Array Containing an Object

See more JSON Examples

Creates a top-level JSON array containing an object.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set jArray = Server.CreateObject("Chilkat.JsonArray")

set json = Server.CreateObject("Chilkat.JsonObject")
success = jArray.AddObjectAt2(0,json)

success = json.UpdateString("groupId","")
success = json.UpdateString("sku","")
success = json.UpdateString("title","")
success = json.UpdateString("barcode","")
success = json.UpdateString("category","")
success = json.UpdateString("description","")
success = json.UpdateString("images[0]","url1")
success = json.UpdateString("images[1]","url...")
success = json.UpdateString("isbn","")
success = json.UpdateString("link","")
success = json.UpdateString("linkLomadee","")
success = json.UpdateString("prices[0].type","")
success = json.UpdateNumber("prices[0].price","0")
success = json.UpdateNumber("prices[0].priceLomadee","0")
success = json.UpdateNumber("prices[0].priceCpa","0")
success = json.UpdateNumber("prices[0].installment","0")
success = json.UpdateNumber("prices[0].installmentValue","0")
success = json.UpdateString("productAttributes.""Atributo 1""","Valor 1")
success = json.UpdateString("productAttributes.""Atributo ...""","Valor ...")
success = json.UpdateString("technicalSpecification.""Especificação 1""","Valor")
success = json.UpdateString("technicalSpecification.""Especificação ...""","Valor ...")
success = json.UpdateNumber("quantity","0")
success = json.UpdateNumber("sizeHeight","0")
success = json.UpdateNumber("sizeLength","0")
success = json.UpdateNumber("sizeWidth","0")
success = json.UpdateNumber("weightValue","0")
success = json.UpdateNumber("declaredPrice","0")
success = json.UpdateNumber("handlingTimeDays","0")
success = json.UpdateBool("marketplace",0)
success = json.UpdateString("marketplaceName","")

jArray.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( jArray.Emit()) & "</pre>"

' The output of this program is:

' [
'   {
'     "groupId": "",
'     "sku": "",
'     "title": "",
'     "barcode": "",
'     "category": "",
'     "description": "",
'     "images": [
'       "url1",
'       "url..."
'     ],
'     "isbn": "",
'     "link": "",
'     "linkLomadee": "",
'     "prices": [
'       {
'         "type": "",
'         "price": 0,
'         "priceLomadee": 0,
'         "priceCpa": 0,
'         "installment": 0,
'         "installmentValue": 0
'       }
'     ],
'     "productAttributes": {
'       "Atributo 1": "Valor 1",
'       "Atributo ...": "Valor ..."
'     },
'     "technicalSpecification": {
'       "Especificação 1": "Valor",
'       "Especificação ...": "Valor ..."
'     },
'     "quantity": 0,
'     "sizeHeight": 0,
'     "sizeLength": 0,
'     "sizeWidth": 0,
'     "weightValue": 0,
'     "declaredPrice": 0,
'     "handlingTimeDays": 0,
'     "marketplace": false,
'     "marketplaceName": ""
'   }
' ]

%>
</body>
</html>