# Using split and join node

Looping logic can be implemented using different nodes in Kumologica. Each node addresses specific requirement needs.

This tutorial will explain on implementing looping logic in Kumologica using split and join node.

  1. Click on Home and select Create New Project

  2. Drag and drop the inject node from the INPUT category in the pallet for triggering the flow.

    TIP

    Trigger node is only used only local testing purpose . This node should be replaced by any other input node like AWS Event node which will allow to expose a trigger (http , S3 etc) based on the need.

  3. Double click the inject node to open the configuration editor.

  4. Paste the following JSON array data in order to simulate the input.

    [{"data":1},{"data":2},{"data":3},{"data":4},{"data":10}]

  5. Drag and drop the split node from the FUNCTION category in the pallet. By default the split node will have the Array split using fixed length as 1. This ensures that the split is always having batch of 1 record.

  6. In this usecase we are adding a simple function node to the split node which will print a message.

    TIP

    In order to close the loop it is mandatory to use join node along with split node.

  7. Double click and open the function editor and provide the console print statement.

    console.log("inside the function");

  8. Drag and drop the join node from the FUNCTION category in the pallet. This node will combine the splited parts which can be joined and passed to next node.

    TIP

    In join node output depends on the logic incorporated between the split and the join node.

  9. Now lets execute the flow. Click on the inject node button .

  10. Click on the Debug panel to see the iteration.

# Using Datampper node

Looping logic can be implemented using different nodes in Kumologica. Each node addresses specific requirement needs.

This tutorial will explain on implementing looping logic in Kumologica using Datampper node.

  1. Click on Home and select Create New Project

  2. Drag and drop the inject node from the INPUT category in the pallet for triggering the flow.

    TIP

    Trigger node is only used only local testing purpose . This node should be replaced by any other input node like AWS Event node which will allow to expose a trigger (http , S3 etc) based on the need.

  3. Double click the inject node to open the configuration editor.

  4. Paste the following JSON array data in order to simulate the input.

    { "name": "John", "age": 30, "cars": [ { "name": "Ford", "models": [ "Fiesta", "Focus", "Mustang" ] }, { "name": "BMW", "models": [ "320", "X3", "X5" ] }, { "name": "Fiat", "models": [ "500", "Panda" ] } ] }

  1. Drag and drop the json node from the PARSER category and wire the inject node to the json node.
  1. Double click the JSON node and select the Always convert to JSON string option and Save the node.

  2. Add the datamapper node from the FUNCTION category on the pallet. Wire the json node to the datamapper node.

  1. Double click and open the datamapper editor. On the Editor mapping section paste the following JSONata expression. Click Save.

    { "Emp_name" : name, "Emp_age" : age, "Car_name": cars.name }

  1. Add the debug node to the end of the flow and wire datamapper node .
  1. Now lets execute the flow. Click on the inject node button .

  2. Click on the Debug panel to see the final output.