Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(Excel) Iterate over JSON Array containing JSON ObjectsDemonstrates how to load a JSON array and iterate over the JSON objects.
' 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.. Dim sbJsonArray As Chilkat.StringBuilder Set sbJsonArray = Chilkat.NewStringBuilder success = sbJsonArray.LoadFile("qa_data/json/arraySample.json","utf-8") Dim arr As Chilkat.JsonArray Set arr = Chilkat.NewJsonArray success = arr.LoadSb(sbJsonArray) i = 0 count = arr.Size Do While i < count Set obj = arr.ObjectAt(i) tagId = obj.IntOf("tagId") tagDescription = obj.StringOf("tagDescription") isPublic = obj.BoolOf("isPublic") Debug.Print "tagId: "; tagId Debug.Print "tagDescription: "; tagDescription Debug.Print "isPublic: "; isPublic Debug.Print "--" i = i + 1 Loop |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.