In my case, I have one array of object that needs to be split based on "L1" occurrence. For example, the below JSON request has multiple L1.
[
{
"route": "F1",
"Company Code": "One Total Item Count"
},
{
"route": "D1",
"Company Code": "Two Total PO Amount"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
},
{
"route": "F1",
"Company Code": "One Total PO Amount"
},
{
"route": "D1",
"Company Code": "Two Total Item Count"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
},
{
"route": "D1",
"Company Code": "Two Total Item Count"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
}
]
I'm trying to split based on L1, and expecting the response like below.
[
[
{
"route": "F1",
"Company Code": "One Total Item Count"
},
{
"route": "D1",
"Company Code": "Two Total PO Amount"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
}
],
[
{
"route": "F1",
"Company Code": "One Total PO Amount"
},
{
"route": "D1",
"Company Code": "Two Total Item Count"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
}
],
[
{
"route": "D1",
"Company Code": "Two Total Item Count"
},
{
"route": "L1",
"Company Code": "Three Total Item Count"
}
]
]
In dataweave I tried spiltAt, filter, and other functions to split by separate sets based on L1 occurrence. but its not working the way I'm expecting.
Expert, please help me solve this logic.
Thanks in advance.