Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Create a JSON Array Containing an ObjectCreates a top-level JSON array containing an object.
#include <C_CkJsonArrayW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkJsonArrayW jArray; HCkJsonObjectW json; jArray = CkJsonArrayW_Create(); CkJsonArrayW_AddObjectAt(jArray,0); json = CkJsonArrayW_ObjectAt(jArray,0); CkJsonObjectW_UpdateString(json,L"groupId",L""); CkJsonObjectW_UpdateString(json,L"sku",L""); CkJsonObjectW_UpdateString(json,L"title",L""); CkJsonObjectW_UpdateString(json,L"barcode",L""); CkJsonObjectW_UpdateString(json,L"category",L""); CkJsonObjectW_UpdateString(json,L"description",L""); CkJsonObjectW_UpdateString(json,L"images[0]",L"url1"); CkJsonObjectW_UpdateString(json,L"images[1]",L"url..."); CkJsonObjectW_UpdateString(json,L"isbn",L""); CkJsonObjectW_UpdateString(json,L"link",L""); CkJsonObjectW_UpdateString(json,L"linkLomadee",L""); CkJsonObjectW_UpdateString(json,L"prices[0].type",L""); CkJsonObjectW_UpdateNumber(json,L"prices[0].price",L"0"); CkJsonObjectW_UpdateNumber(json,L"prices[0].priceLomadee",L"0"); CkJsonObjectW_UpdateNumber(json,L"prices[0].priceCpa",L"0"); CkJsonObjectW_UpdateNumber(json,L"prices[0].installment",L"0"); CkJsonObjectW_UpdateNumber(json,L"prices[0].installmentValue",L"0"); CkJsonObjectW_UpdateString(json,L"productAttributes.\"Atributo 1\"",L"Valor 1"); CkJsonObjectW_UpdateString(json,L"productAttributes.\"Atributo ...\"",L"Valor ..."); CkJsonObjectW_UpdateString(json,L"technicalSpecification.\"Especificação 1\"",L"Valor"); CkJsonObjectW_UpdateString(json,L"technicalSpecification.\"Especificação ...\"",L"Valor ..."); CkJsonObjectW_UpdateNumber(json,L"quantity",L"0"); CkJsonObjectW_UpdateNumber(json,L"sizeHeight",L"0"); CkJsonObjectW_UpdateNumber(json,L"sizeLength",L"0"); CkJsonObjectW_UpdateNumber(json,L"sizeWidth",L"0"); CkJsonObjectW_UpdateNumber(json,L"weightValue",L"0"); CkJsonObjectW_UpdateNumber(json,L"declaredPrice",L"0"); CkJsonObjectW_UpdateNumber(json,L"handlingTimeDays",L"0"); CkJsonObjectW_UpdateBool(json,L"marketplace",FALSE); CkJsonObjectW_UpdateString(json,L"marketplaceName",L""); CkJsonArrayW_putEmitCompact(jArray,FALSE); wprintf(L"%s\n",CkJsonArrayW_emit(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": "" // } // ] CkJsonArrayW_Dispose(jArray); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.