Problem with Nested Split in batches loop workflow - lack of last element

Hi n8n team,

I created this workflow that using nested Split in batches loop. The problem is the SplitInBatches1 does not show the last “113.166.127.111”, instead it uses duplicated value from penultimate value “211.85.221.45”. Can you help me?

Hey @mrluanpham!

Welcome to the community :sparkling_heart:

It seems like the workflow code you’ve shared is incomplete. Can you please update it?

A similar question was asked earlier. Maybe the solution I shared there can be helpful to you as well :slight_smile:

Thanks for your great tool, I updated the workflow code, please help me to review. And yes, I reviewed that topic, but some problems with my data pipeline. I think that’s Reset button problem, because my beginning data is Nested json array. Please help me

Unfortunately, there is still some issue with your workflow code. You can check the video to know how you can share the workflow code: How can I contribute? | Docs

I’ve used the workflow from the other post, and modified it a bit. Hopefully, this might be helpful,

Hmm, I tried some ways but my pasted code on forum cannot work when getting paste back.
Can you review my input, some problems with your workflow code when I apply it.

[
[
{
"id": "85266",
"info": "Test 1",
"Attribute": [
{
"type": "ip",
"category": "Network",
"value": "20.2.95.38"
},
{
"type": "ip",
"category": "Network",
"value": "118.69.96.3"
},
{
"type": "ip",
"category": "Network",
"value": "220.255.236.153"
}
]
},
{
"id": "87693",
"info": "Test 2",
"Attribute": [
{
"id": "5344351",
"type": "ip",
"category": "Network",
"value": "211.85.221.45"
},
{
"id": "5344354",
"type": "ip",
"category": "Network",
"value": "113.166.127.111"
}
]
},
{
"id": "87693",
"info": "Test 2",
"Attribute": [
{
"id": "5344351",
"type": "ip",
"category": "Network",
"value": "211.85.221.45"
},
{
"id": "5344354",
"type": "ip",
"category": "Network",
"value": "113.166.127.111"
}
]
}
]
];

You will have to transform the structure of the input data. Here’s the code snippet that you can refer to:

1 Like

Thanks harshil, by using Javascript code snippets, I changed my workflow to a easier one.

1 Like

I am glad you found a solution! Can you share the solution here? Other members facing the same issue can benefit from your solution :slight_smile:

Instead if using nested JSON and 2 SplitInBatches for 2 loops. I convert nested JSON into JSON array (no nested field) and 1 SplitInBatches.
My solution is that separate 2 loops instead of using nested loop for nested JSON.
Thanks

1 Like