I am trying to use the sum function of JMESPath but having some trouble. I managed to figure out how to use the search function with multiple conditions. This statement:
var x = search(myData, "Account[].Details[? Year=='2018' && Title=='ABC'].Amount");
returns this JSON array:
["2404.00", "2404.00", "2402.67", "2699.00", "2699.00", "2698.49"]
Now what I would like to do is to sum these values. The JMESPath specification says to use this syntax for the built-in sum function:
number sum(array[number] $collection)
I don't understand how to use this function. Can someone please help?