Having some trouble splitting a payload up. I basically need to split the payload every time we come across the {“type”: “AA”} object.
This is my input payload –
[
{
"type": "AA",
"content": "someContent"
},
{
"type": "AB",
"content": "someContent"
},
{
"type": "AC",
"content": "someContent"
},
{
"type": "MH",
"content": "someContent"
},
{
"type": "AA",
"content": "someContent"
},
{
"type": "AB",
"content": "someContent"
},
{
"type": "AC",
"content": "someContent"
},
{
"type": "QP",
"content": "someContent"
}
]
And what I need to happen is every time we come across the {“type”: “AA”} we need to create an array and include all proceeding objects in that array. So this is what the output would look like
[
[{
"type": "AA",
"content": "someContent"
},
{
"type": "AB",
"content": "someContent"
},
{
"type": "AC",
"content": "someContent"
},
{
"type": "MH",
"content": "someContent"
}],
[{
"type": "AA",
"content": "someContent"
},
{
"type": "AB",
"content": "someContent"
},
{
"type": "AC",
"content": "someContent"
},
{
"type": "QP",
"content": "someContent"
}]
]
You can see from the output we have multiple arrays with the first element being the object {“type”: “AA”}.. Any help in achieving this output would be greatly appreciated