Forum Discussion
j_angelevski
5 years agoContributor III
@kkishore, assuming that the last object will be in the format that you provided, you can implement the following solution.
-
Group by N - to group the input data in a single array
-
Mapper
Use the following expression, with this you can add the'count'object to each input document.
$group.filter(val => val.get("count") == null).map(val => val.extend($group[$group.length - 1]))
Target path: $array
Result:
{
"array": [
{
"filename": "a1.dat",
"count": 2,
"type": "pdf"
},
{
"filename": "a2.dat",
"count": 2,
"type": "pdf"
}
]
}
After this, you can use a JSON Splitter if you want to split the array.
- kkishore5 years agoNew Contributor III
Hi @j.angelevski ,
Thanks for the response and it is working as expected.