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
(DataFlex) JSON AddObjectCopyAt ExampleDemonstrates the AddObjectCopyAt function. Note: This example requires Chilkat v9.5.0.82 or above.
Use ChilkatAx-win32.pkg Procedure Test Handle hoJson Boolean iSuccess Variant vJson2 Handle hoJson2 String sTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson '{ "name": "John", "marbles": 100 }' To iSuccess Get Create (RefClass(cComChilkatJsonObject)) To hoJson2 If (Not(IsComObjectCreated(hoJson2))) Begin Send CreateComObject of hoJson2 End Get ComLoad Of hoJson2 '{"street":"1200 Elm St.","city":"Springfield","zip":60606}' To iSuccess // Copy the contents of json2 to a new member object named "addr". // Insert it in the 2nd position. Get pvComObject of hoJson2 to vJson2 Get ComAddObjectCopyAt Of hoJson 1 "addr" vJson2 To iSuccess Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // Expected output is: {"name":"John","addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606},"marbles":100} // Note: Modifying the contents of json does not modify the contents of json2 (because the contents of json2 were copied). // For example: Get ComUpdateString Of hoJson "addr.street" "1000 Oak St." To iSuccess Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // Expected output is: {"name":"John","addr":{"street":"1000 Oak St.","city":"Springfield","zip":60606},"marbles":100} Get ComEmit Of hoJson2 To sTemp1 Showln sTemp1 // Expected output is: {"street":"1200 Elm St.","city":"Springfield","zip":60606} End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.