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
(PureBasic) JSON Copy ObjectsCopy objects from one JSON document to another.
IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() json1.i = CkJsonObject::ckCreate() If json1.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json1,"ID1.cn","Name") CkJsonObject::ckUpdateString(json1,"ID1.objectGUID","GUID") CkJsonObject::ckUpdateString(json1,"ID2.cn","Name") CkJsonObject::ckUpdateString(json1,"ID2.objectGUID","GUID") CkJsonObject::setCkEmitCompact(json1, 0) Debug CkJsonObject::ckEmit(json1) ; json1 contains: ; { ; "ID1": { ; "cn": "Name", ; "objectGUID": "GUID" ; }, ; "ID2": { ; "cn": "Name", ; "objectGUID": "GUID" ; } ; } json2.i = CkJsonObject::ckCreate() If json2.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json2,"Name1.ID1.cn","Name") CkJsonObject::ckUpdateString(json2,"Name1.ID1.objectGUID","GUID") CkJsonObject::ckUpdateString(json2,"Name1.ID2.cn","Name") CkJsonObject::ckUpdateString(json2,"Name1.ID2.objectGUID","GUID") CkJsonObject::ckUpdateString(json2,"Name2.ID3.cn","Name") CkJsonObject::ckUpdateString(json2,"Name2.ID3.objectGUID","GUID") CkJsonObject::setCkEmitCompact(json2, 0) Debug CkJsonObject::ckEmit(json2) ; { ; "Name1": { ; "ID1": { ; "cn": "Name", ; "objectGUID": "GUID" ; }, ; "ID2": { ; "cn": "Name", ; "objectGUID": "GUID" ; } ; }, ; "Name2": { ; "ID3": { ; "cn": "Name", ; "objectGUID": "GUID" ; } ; } ; } ; Copy Name1, Name2 into json1 i.i = 0 numMembers.i = CkJsonObject::ckSize(json2) While i < numMembers jsonObj.i = CkJsonObject::ckObjectAt(json2,i) CkJsonObject::ckAppendObjectCopy(json1,CkJsonObject::ckNameAt(json2,i),jsonObj) i = i + 1 Wend ; Now see what json1 contains: Debug CkJsonObject::ckEmit(json1) ; { ; "ID1": { ; "cn": "Name", ; "objectGUID": "GUID" ; }, ; "ID2": { ; "cn": "Name", ; "objectGUID": "GUID" ; }, ; "Name1": { ; "ID1": { ; "cn": "Name", ; "objectGUID": "GUID" ; }, ; "ID2": { ; "cn": "Name", ; "objectGUID": "GUID" ; } ; }, ; "Name2": { ; "ID3": { ; "cn": "Name", ; "objectGUID": "GUID" ; } ; } ; } CkJsonObject::ckDispose(json1) CkJsonObject::ckDispose(json2) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.