Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) Create a JSON Array Containing an ObjectCreates a top-level JSON array containing an object.
#include <CkJsonArray.h> #include <CkJsonObject.h> void ChilkatSample(void) { CkString strOut; CkJsonArray jArray; jArray.AddObjectAt(0); CkJsonObject *json = jArray.ObjectAt(0); json->UpdateString("groupId",""); json->UpdateString("sku",""); json->UpdateString("title",""); json->UpdateString("barcode",""); json->UpdateString("category",""); json->UpdateString("description",""); json->UpdateString("images[0]","url1"); json->UpdateString("images[1]","url..."); json->UpdateString("isbn",""); json->UpdateString("link",""); json->UpdateString("linkLomadee",""); json->UpdateString("prices[0].type",""); json->UpdateNumber("prices[0].price","0"); json->UpdateNumber("prices[0].priceLomadee","0"); json->UpdateNumber("prices[0].priceCpa","0"); json->UpdateNumber("prices[0].installment","0"); json->UpdateNumber("prices[0].installmentValue","0"); json->UpdateString("productAttributes.\"Atributo 1\"","Valor 1"); json->UpdateString("productAttributes.\"Atributo ...\"","Valor ..."); json->UpdateString("technicalSpecification.\"Especificação 1\"","Valor"); json->UpdateString("technicalSpecification.\"Especificação ...\"","Valor ..."); json->UpdateNumber("quantity","0"); json->UpdateNumber("sizeHeight","0"); json->UpdateNumber("sizeLength","0"); json->UpdateNumber("sizeWidth","0"); json->UpdateNumber("weightValue","0"); json->UpdateNumber("declaredPrice","0"); json->UpdateNumber("handlingTimeDays","0"); json->UpdateBool("marketplace",false); json->UpdateString("marketplaceName",""); jArray.put_EmitCompact(false); strOut.append(jArray.emit()); strOut.append("\r\n"); // 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": "" // } // ] SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.