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
(PowerBuilder) Merge SP-API JSON Order ArraysSee more Amazon SP-API ExamplesDemonstrates how to merge JSON arrays for the case of Amazon SP-API orders.
integer li_rc string ls_A1 string ls_A2 integer li_Success oleobject loo_Json1 oleobject loo_Json2 oleobject loo_Jarr1 oleobject loo_Jarr2 integer i integer li_NumOrders oleobject loo_JOrder // Batch 1 File ls_A1 = "{~"payload~": {~"Orders~": [{~"AmazonOrderId~": ~"1~",~"OrderStatus~": ~"Unshipped~"},{~"AmazonOrderId~": ~"2~",~"OrderStatus~": ~"Unshipped~"}]}" // Batch 2 File ls_A2 = "{~"payload~": {~"Orders~": [{~"AmazonOrderId~": ~"3~",~"OrderStatus~": ~"Unshipped~"},{~"AmazonOrderId~": ~"4~",~"OrderStatus~": ~"Unshipped~"}]}" // Required Merged File // {"payload": {"Orders": [{"AmazonOrderId": "1","OrderStatus": "Unshipped"},{"AmazonOrderId": "2","OrderStatus": "Unshipped"},{"AmazonOrderId": "3","OrderStatus": "Unshipped"},{"AmazonOrderId": "4","OrderStatus": "Unshipped"}]} li_Success = 1 loo_Json1 = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json1.ConnectToNewObject("Chilkat.JsonObject") if li_rc < 0 then destroy loo_Json1 MessageBox("Error","Connecting to COM object failed") return end if loo_Json1.Load(ls_A1) loo_Json2 = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json2.ConnectToNewObject("Chilkat.JsonObject") loo_Json2.Load(ls_A2) // We're going to add the order records from json2 to json1. loo_Jarr1 = loo_Json1.ArrayOf("payload.Orders") loo_Jarr2 = loo_Json2.ArrayOf("payload.Orders") i = 0 li_NumOrders = loo_Jarr2.Size do while (i < li_NumOrders) loo_JOrder = loo_Jarr2.ObjectAt(i) // Assuming non-null return... loo_Jarr1.AddObjectCopyAt(-1,loo_JOrder) i = i + 1 loop // Show the merged JSON. loo_Json1.EmitCompact = 0 Write-Debug loo_Json1.Emit() // Result: // { // "payload": { // "Orders": [ // { // "AmazonOrderId": "1", // "OrderStatus": "Unshipped" // }, // { // "AmazonOrderId": "2", // "OrderStatus": "Unshipped" // }, // { // "AmazonOrderId": "3", // "OrderStatus": "Unshipped" // }, // { // "AmazonOrderId": "4", // "OrderStatus": "Unshipped" // } // ] // } // } destroy loo_Json1 destroy loo_Json2 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.