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
(PowerBuilder) Create a JSON Array of ObjectsDemonstrates how to create a JSON array of objects.
integer li_rc oleobject loo_Arr integer li_Success oleobject loo_Obj loo_Arr = create oleobject // Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0 li_rc = loo_Arr.ConnectToNewObject("Chilkat.JsonArray") if li_rc < 0 then destroy loo_Arr MessageBox("Error","Connecting to COM object failed") return end if // Add an empty object at the 1st JSON array position. loo_Arr.AddObjectAt(0) // Get the object we just created. loo_Obj = loo_Arr.ObjectAt(0) loo_Obj.UpdateString("Name","Otto") loo_Obj.UpdateInt("Age",29) loo_Obj.UpdateBool("Married",0) destroy loo_Obj // Add an empty object at the 2nd JSON array position. loo_Arr.AddObjectAt(1) loo_Obj = loo_Arr.ObjectAt(1) loo_Obj.UpdateString("Name","Connor") loo_Obj.UpdateInt("Age",43) loo_Obj.UpdateBool("Married",1) destroy loo_Obj // Add an empty object at the 3rd JSON array position. loo_Arr.AddObjectAt(2) loo_Obj = loo_Arr.ObjectAt(2) loo_Obj.UpdateString("Name","Ramona") loo_Obj.UpdateInt("Age",34) loo_Obj.UpdateBool("Married",1) destroy loo_Obj // Examine what we have: loo_Arr.EmitCompact = 0 Write-Debug loo_Arr.Emit() // The output is: // [ // { // "Name": "Otto", // "Age": 29, // "Married": false // }, // { // "Name": "Connor", // "Age": 43, // "Married": true // }, // { // "Name": "Ramona", // "Age": 34, // "Married": true // } // ] destroy loo_Arr |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.