0

I am trying to find the max() for the below json string using JsonPath, but it throws an error Aggregation function attempted to calculate value using empty array. Please let know what will be correct JsonPath to get the max value.

[
    {"question":"pattern1","time":1},
    {"question":"pattern2","time":5}, 
    {"question":"pattern2","time":4}
]

$..time -- returns [1,5,4]
$..time.max() -- throws an error
AxelH
  • 14,325
  • 2
  • 25
  • 55
skumar
  • 985
  • 4
  • 14
  • 37
  • Possible duplicate of [Functions min(), max() or sum() with jsonpath](https://stackoverflow.com/questions/52817156/functions-min-max-or-sum-with-jsonpath) – AxelH Aug 16 '19 at 14:23
  • The solution would be to search the max value in the `$..time` result yourself. – AxelH Aug 16 '19 at 14:25
  • can you please be more specific? what will be the exact jsonPath? – skumar Aug 16 '19 at 15:30
  • More specific would be to write the solution. You already have the `JsonPath` to retrieve every "time" in an array. Iterate the result and sum those value. There is no solution using `JsonPath` to sum those value. The structure is incorrect (as explain in the duplicate question) – AxelH Aug 19 '19 at 05:48

0 Answers0