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
(Visual FoxPro) Iterate over JSON Array containing JSON ObjectsDemonstrates how to load a JSON array and iterate over the JSON objects.
LOCAL loSbJsonArray LOCAL lnSuccess LOCAL loArr LOCAL lnTagId LOCAL lcTagDescription LOCAL lnIsPublic LOCAL i LOCAL lnCount LOCAL loObj * Loads the following JSON array and iterates over the objects: * * [ * {"tagId":95,"tagDescription":"hola 1","isPublic":true}, * {"tagId":98,"tagDescription":"hola 1","isPublic":true}, * {"tagId":101,"tagDescription":"hola 1","isPublic":true}, * {"tagId":104,"tagDescription":"hola 1","isPublic":true}, * {"tagId":107,"tagDescription":"hola 1","isPublic":true}, * {"tagId":110,"tagDescription":"hola 1","isPublic":true}, * {"tagId":113,"tagDescription":"hola 1","isPublic":true}, * {"tagId":114,"tagDescription":"hola 2","isPublic":true}, * {"tagId":111,"tagDescription":"hola 2","isPublic":true}, * {"tagId":108,"tagDescription":"hola 2","isPublic":true}, * {"tagId":105,"tagDescription":"hola 2","isPublic":true}, * {"tagId":102,"tagDescription":"hola 2","isPublic":true}, * {"tagId":99,"tagDescription":"hola 2","isPublic":true}, * {"tagId":96,"tagDescription":"hola 2","isPublic":true}, * {"tagId":97,"tagDescription":"hola 3","isPublic":true}, * {"tagId":100,"tagDescription":"hola 3","isPublic":true}, * {"tagId":103,"tagDescription":"hola 3","isPublic":true}, * {"tagId":106,"tagDescription":"hola 3","isPublic":true}, * {"tagId":109,"tagDescription":"hola 3","isPublic":true}, * {"tagId":112,"tagDescription":"hola 3","isPublic":true}, * {"tagId":115,"tagDescription":"hola 3","isPublic":true}, * {"tagId":93,"tagDescription":"new tag","isPublic":true}, * {"tagId":94,"tagDescription":"new tag","isPublic":true}, * {"tagId":89,"tagDescription":"tag 1","isPublic":true}, * {"tagId":90,"tagDescription":"tag 2","isPublic":true}, * {"tagId":91,"tagDescription":"tag private 1","isPublic":false}, * {"tagId":92,"tagDescription":"tag private 2","isPublic":false} * ] * Load a file containing the above JSON.. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbJsonArray = CreateObject('Chilkat.StringBuilder') lnSuccess = loSbJsonArray.LoadFile("qa_data/json/arraySample.json","utf-8") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonArray') loArr = CreateObject('Chilkat.JsonArray') lnSuccess = loArr.LoadSb(loSbJsonArray) i = 0 lnCount = loArr.Size DO WHILE i < lnCount loObj = loArr.ObjectAt(i) lnTagId = loObj.IntOf("tagId") lcTagDescription = loObj.StringOf("tagDescription") lnIsPublic = loObj.BoolOf("isPublic") ? "tagId: " + STR(lnTagId) ? "tagDescription: " + lcTagDescription ? "isPublic: " + STR(lnIsPublic) ? "--" RELEASE loObj i = i + 1 ENDDO RELEASE loSbJsonArray RELEASE loArr |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.