Solved
Forum Discussion
Supratim
2 years agoContributor III
vgautam64 As I can't copy your json, have created my own, you can use it-
Data ==>
{
"carList": [
{
"color": "purple",
"type": "minivan",
"debit_amount": 50,
"credit_amount": 7
},
{
"color": "red",
"type": "station wagon",
"debit_amount": 100,
"credit_amount": 5
}, {
"color": "black",
"type": "toyota",
"debit_amount": 200,
"credit_amount": 5
},
{
"color": "blue",
"type": "Maruti",
"debit_amount": 300,
"credit_amount": 5
}
]
}
1. mapper :
$carList.map((val,index)=>{"sum_debit_amount": jsonPath($, "carList[*].debit_amount").reduce((cur,acc)=>cur+acc),"sum_credit_amount" : jsonPath($, "carList[*].credit_amount").reduce((cur,acc)=>cur+acc)}.extend(val)).shift()
- vgautam642 years agoNew Contributor III
Hi Supratim,
Thanks for the providing a solution. I tried to validate the expression with the data I have and it seems to work when I validate the pipe. Strangely though, I observe that when I execute (not validate) the pipeline, the mapper that holds the expression only seem to process 50 records and gets stuck processing the 51st doc. But when I validate the pipe I am able to see the preview of 148 documents.
Any idea why this would happen?