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 Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(VBScript) JSON: Renaming and Deleting MembersDemonstrates renaming and deleting members. This example uses the following JSON document: { "apple": "red", "lime": "green", "banana": "yellow", "broccoli": "green", "strawberry": "red" }
Dim fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") Set outFile = fso.CreateTextFile("output.txt", True) set json = CreateObject("Chilkat_9_5_0.JsonObject") success = json.Load("{""apple"": ""red"",""lime"": ""green"",""banana"": ""yellow"",""broccoli"": ""green"",""strawberry"": ""red""}") If (success <> 1) Then outFile.WriteLine(json.LastErrorText) WScript.Quit End If ' Rename "lime" to "lemon". success = json.Rename("lime","lemon") ' Change the color to yellow: success = json.SetStringOf("lemon","yellow") ' Rename by index. Banana is at index 2 (apple is at index 0) success = json.RenameAt(2,"bartlett_pear") ' Delete broccoli by name success = json.Delete("broccoli") ' Delete apple by index. Apple is at index 0. success = json.DeleteAt(0) json.EmitCompact = 0 outFile.WriteLine(json.Emit()) outFile.Close |
© 2000-2016 Chilkat Software, Inc. All Rights Reserved.