![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Swift) Create a JSON Array Containing an ObjectCreates a top-level JSON array containing an object. Note: This example requires Chilkat v11.1.0 or greater.
func chilkatTest() { let jArray = CkoJsonArray()! let json = CkoJsonObject()! jArray.addObjectAt2(0, json: json) json.update("groupId", value: "") json.update("sku", value: "") json.update("title", value: "") json.update("barcode", value: "") json.update("category", value: "") json.update("description", value: "") json.update("images[0]", value: "url1") json.update("images[1]", value: "url...") json.update("isbn", value: "") json.update("link", value: "") json.update("linkLomadee", value: "") json.update("prices[0].type", value: "") json.updateNumber("prices[0].price", numericStr: "0") json.updateNumber("prices[0].priceLomadee", numericStr: "0") json.updateNumber("prices[0].priceCpa", numericStr: "0") json.updateNumber("prices[0].installment", numericStr: "0") json.updateNumber("prices[0].installmentValue", numericStr: "0") json.update("productAttributes.\"Atributo 1\"", value: "Valor 1") json.update("productAttributes.\"Atributo ...\"", value: "Valor ...") json.update("technicalSpecification.\"Especificação 1\"", value: "Valor") json.update("technicalSpecification.\"Especificação ...\"", value: "Valor ...") json.updateNumber("quantity", numericStr: "0") json.updateNumber("sizeHeight", numericStr: "0") json.updateNumber("sizeLength", numericStr: "0") json.updateNumber("sizeWidth", numericStr: "0") json.updateNumber("weightValue", numericStr: "0") json.updateNumber("declaredPrice", numericStr: "0") json.updateNumber("handlingTimeDays", numericStr: "0") json.updateBool("marketplace", value: false) json.update("marketplaceName", value: "") jArray.emitCompact = false print("\(jArray.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": "" // } // ] } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.