Open
Description
Motivation
I have a json like this:
{
"contactMedium": [
{
"@type": "EmailContactMedium",
"preferred": true,
"contactType": "other",
"validFor": {
"startDateTime": "2018-10-22T08:31:52.028Z"
},
"emailAddress": "tom@email.com"
},
{
"@type": "GeographicAddressContactMedium",
"preferred": true,
"contactType": "other",
"validFor": {
"startDateTime": "2018-10-22T08:31:52.028Z"
},
}
]
}
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)