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
(MFC) 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" }
#include <CkJsonObject.h> void ChilkatSample(void) { CkString strOut; CkJsonObject json; bool success = json.Load("{\"apple\": \"red\",\"lime\": \"green\",\"banana\": \"yellow\",\"broccoli\": \"green\",\"strawberry\": \"red\"}"); if (success != true) { strOut.append(json.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // 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.put_EmitCompact(false); strOut.append(json.emit()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.