I want to get the number of item with preferred==true
const result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)].length', json: data })
Current behavior
got []
Desired behavior
got 2
Alternatives considered
currently, i can got the result expected by this way.
const result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)]', json: data })
console.log(result)
const result2 = JSONPath({ path: '$.length', json: result })
console.log(result2)
Motivation
I have a json like this:
I want to get the number of item with preferred==true const result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)].length', json: data })
Current behavior
got []
Desired behavior
got 2
Alternatives considered
currently, i can got the result expected by this way. const result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)]', json: data }) console.log(result)
const result2 = JSONPath({ path: '$.length', json: result }) console.log(result2)