![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript 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
(PureBasic) Example: JsonObject.NewObjectOf methodDemonstrates the Note: This example requires Chilkat v11.4.0 or greater.
IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() success.i = 0 car.s = "{" + Chr(34) + "make" + Chr(34) + ":" + Chr(34) + "Toyota" + Chr(34) + "," + Chr(34) + "model" + Chr(34) + ":" + Chr(34) + "Camry" + Chr(34) + "," + Chr(34) + "year" + Chr(34) + ":2022," + Chr(34) + "color" + Chr(34) + ":" + Chr(34) + "silver" + Chr(34) + "," + Chr(34) + "engine" + Chr(34) + ":{" + Chr(34) + "type" + Chr(34) + ":" + Chr(34) + "inline-4" + Chr(34) + "," + Chr(34) + "fuel" + Chr(34) + ":" + Chr(34) + "gasoline" + Chr(34) + "," + Chr(34) + "horsepower" + Chr(34) + ":203}," + Chr(34) + "features" + Chr(34) + ":[" + Chr(34) + "bluetooth" + Chr(34) + "," + Chr(34) + "backup camera" + Chr(34) + "," + Chr(34) + "adaptive cruise control" + Chr(34) + "," + Chr(34) + "lane assist" + Chr(34) + "]," + Chr(34) + "isElectric" + Chr(34) + ":false}" json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json,"test","abc") success = CkJsonObject::ckNewObjectOf(json,"car",car) If success = 0 Debug CkJsonObject::ckLastErrorText(json) CkJsonObject::ckDispose(json) ProcedureReturn EndIf CkJsonObject::setCkEmitCompact(json, 0) Debug CkJsonObject::ckEmit(json) ; Result: ; { ; "test": "abc", ; "car": { ; "make": "Toyota", ; "model": "Camry", ; "year": 2022, ; "color": "silver", ; "engine": { ; "type": "inline-4", ; "fuel": "gasoline", ; "horsepower": 203 ; }, ; "features": [ ; "bluetooth", ; "backup camera", ; "adaptive cruise control", ; "lane assist" ; ], ; "isElectric": false ; } ; } CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.