9.3. Manipulating and Restructuring JSON Data
Often when you call methods from different APIs, the response object may not come back in a desired format. You may get more data back than you actually need, or the response may contain nested objects or arrays.
Cyclr has a limit to the amount of nested objects/arrays which it can map to, the limit is 3. Since Cyclr can only map to a maximum of three levels of nested objects or arrays, it may become necessary to restructure the response to fit within these limitations.
How to Manipulate JSON Data
With Cyclr, you can use JavaScript to manipulate the method response to only include required data in the response. You can access this by using method_reponse in an after_action() function.
To pull data from a nested object or an array, and store it at the root level, you can add a script to the Cycle step where the method is used. To do this, click on the Step Setup icon, and access the ‘Advanced Settings’. This will open a box where you can add your script.
