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
(Visual FoxPro) Merge SP-API JSON Order ArraysSee more Amazon SP-API ExamplesDemonstrates how to merge JSON arrays for the case of Amazon SP-API orders.
LOCAL lcA1 LOCAL lcA2 LOCAL lnSuccess LOCAL loJson1 LOCAL loJson2 LOCAL loJarr1 LOCAL loJarr2 LOCAL i LOCAL lnNumOrders LOCAL loJOrder * Batch 1 File lcA1 = '{"payload": {"Orders": [{"AmazonOrderId": "1","OrderStatus": "Unshipped"},{"AmazonOrderId": "2","OrderStatus": "Unshipped"}]}' * Batch 2 File lcA2 = '{"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"}]} lnSuccess = 1 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson1 = CreateObject('Chilkat.JsonObject') loJson1.Load(lcA1) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson2 = CreateObject('Chilkat.JsonObject') loJson2.Load(lcA2) * We're going to add the order records from json2 to json1. loJarr1 = loJson1.ArrayOf("payload.Orders") loJarr2 = loJson2.ArrayOf("payload.Orders") i = 0 lnNumOrders = loJarr2.Size DO WHILE (i < lnNumOrders) loJOrder = loJarr2.ObjectAt(i) * Assuming non-null return... loJarr1.AddObjectCopyAt(-1,loJOrder) i = i + 1 ENDDO * Show the merged JSON. loJson1.EmitCompact = 0 ? loJson1.Emit() * Result: * { * "payload": { * "Orders": [ * { * "AmazonOrderId": "1", * "OrderStatus": "Unshipped" * }, * { * "AmazonOrderId": "2", * "OrderStatus": "Unshipped" * }, * { * "AmazonOrderId": "3", * "OrderStatus": "Unshipped" * }, * { * "AmazonOrderId": "4", * "OrderStatus": "Unshipped" * } * ] * } * } RELEASE loJson1 RELEASE loJson2 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.