Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.1.0+

Create a JSON Array Containing an Object

See more JSON Examples

Creates a top-level JSON array containing an object.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL loJArray
LOCAL loJson

loJArray = CreateObject('Chilkat.JsonArray')

loJson = CreateObject('Chilkat.JsonObject')
loJArray.AddObjectAt2(0,loJson)

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

loJArray.EmitCompact = 0
? loJArray.Emit()

*  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": ""
*    }
*  ]

RELEASE loJArray
RELEASE loJson