PureBasic
PureBasic
Create a JSON Array Containing an Object
See more JSON Examples
Creates a top-level JSON array containing an object.Chilkat PureBasic Downloads
IncludeFile "CkJsonArray.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
jArray.i = CkJsonArray::ckCreate()
If jArray.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonArray::ckAddObjectAt2(jArray,0,json)
CkJsonObject::ckUpdateString(json,"groupId","")
CkJsonObject::ckUpdateString(json,"sku","")
CkJsonObject::ckUpdateString(json,"title","")
CkJsonObject::ckUpdateString(json,"barcode","")
CkJsonObject::ckUpdateString(json,"category","")
CkJsonObject::ckUpdateString(json,"description","")
CkJsonObject::ckUpdateString(json,"images[0]","url1")
CkJsonObject::ckUpdateString(json,"images[1]","url...")
CkJsonObject::ckUpdateString(json,"isbn","")
CkJsonObject::ckUpdateString(json,"link","")
CkJsonObject::ckUpdateString(json,"linkLomadee","")
CkJsonObject::ckUpdateString(json,"prices[0].type","")
CkJsonObject::ckUpdateNumber(json,"prices[0].price","0")
CkJsonObject::ckUpdateNumber(json,"prices[0].priceLomadee","0")
CkJsonObject::ckUpdateNumber(json,"prices[0].priceCpa","0")
CkJsonObject::ckUpdateNumber(json,"prices[0].installment","0")
CkJsonObject::ckUpdateNumber(json,"prices[0].installmentValue","0")
CkJsonObject::ckUpdateString(json,"productAttributes." + Chr(34) + "Atributo 1" + Chr(34),"Valor 1")
CkJsonObject::ckUpdateString(json,"productAttributes." + Chr(34) + "Atributo ..." + Chr(34),"Valor ...")
CkJsonObject::ckUpdateString(json,"technicalSpecification." + Chr(34) + "Especificação 1" + Chr(34),"Valor")
CkJsonObject::ckUpdateString(json,"technicalSpecification." + Chr(34) + "Especificação ..." + Chr(34),"Valor ...")
CkJsonObject::ckUpdateNumber(json,"quantity","0")
CkJsonObject::ckUpdateNumber(json,"sizeHeight","0")
CkJsonObject::ckUpdateNumber(json,"sizeLength","0")
CkJsonObject::ckUpdateNumber(json,"sizeWidth","0")
CkJsonObject::ckUpdateNumber(json,"weightValue","0")
CkJsonObject::ckUpdateNumber(json,"declaredPrice","0")
CkJsonObject::ckUpdateNumber(json,"handlingTimeDays","0")
CkJsonObject::ckUpdateBool(json,"marketplace",0)
CkJsonObject::ckUpdateString(json,"marketplaceName","")
CkJsonArray::setCkEmitCompact(jArray, 0)
Debug CkJsonArray::ckEmit(jArray)
; 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": ""
; }
; ]
CkJsonArray::ckDispose(jArray)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure