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) Load a JSON ArrayThe Chilkat JSON API requires the top-level JSON to be an object. Therefore, to load an array requires that it first be wrapped as an object.
integer li_rc integer li_Success string ls_JsonArrayStr oleobject loo_SbJson oleobject loo_Json oleobject loo_JArray oleobject loo_JObjId // Imagine we want to load this JSON array for parsing: ls_JsonArrayStr = "[{~"id~":200},{~"id~":196}]" // First wrap it in a JSON object by prepending "{ "array":" and appending "}" loo_SbJson = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder") if li_rc < 0 then destroy loo_SbJson MessageBox("Error","Connecting to COM object failed") return end if loo_SbJson.Append("{~"array~":") loo_SbJson.Append(ls_JsonArrayStr) loo_SbJson.Append("}") loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.Load(loo_SbJson.GetAsString()) // Now we can get the JSON array loo_JArray = loo_Json.ArrayAt(0) // Do what you want with the JSON array... // For example: loo_JObjId = loo_JArray.ObjectAt(0) Write-Debug string(loo_JObjId.IntOf("id")) destroy loo_JObjId destroy loo_JArray destroy loo_SbJson destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.