Forum Discussion
ivicakoteski
2 years agoNew Contributor III
Hi vonkendu,
You can use a wildcard operator to select all values from an array or an object, in your case from parameterOne and parameterTwo. After you get the needed array, using the reduce() function you can return the sum of all of the elements in the array.:
jsonPath($, "$parameters[*][*][*].parameterTwo").reduce((accum, currentValue) => accum+ currentValue, 0)
jsonPath($, "$parameters[*][*][*].parameterTwo").reduce((accum, currentValue) => accum+ currentValue, 0)
If the name will always be an array with a single element, take the first element of the array to make it flattened.
Please check the attached pipeline.
Hope this helps!
BR.
Ivica