Parsing data from array

136 views
Skip to first unread message

Mikael Wallin

unread,
Oct 14, 2015, 3:59:23 AM10/14/15
to JsonPath
I have following json. (An undetermined size of "action" objects of various kinds).

{
actions:[
  • {},
  • {},
  • {
    • failCount1,
    • skipCount0,
    • totalCount33,
    • urlName"testReport"
    }
],
}

I want to extract the value if failCount.

So far I have come up with:

"$.actions.[?((@.failCount)&&(@.failCount)&&(@.totalCount))]"


but the result doesn't let me access failCount ie. "$.actions.[?((@.failCount)&&(@.failCount)&&(@.totalCount))].failCount" doesn't work as the result is an array.

kalle stenflo

unread,
Oct 14, 2015, 12:24:26 PM10/14/15
to JsonPath
Given JSON:

{
   
"actions": [
       
{},
       
{},
       
{
           
"failCount": 1,
           
"skipCount": 0,
           
"totalCount": 33,
           
"urlName": "testReport"
       
}
   
]
}

Evaluating path

$.actions[?(@.failCount)].failCount

Returns

[ 1 ]

Rajukamal R

unread,
Apr 28, 2016, 1:39:07 AM4/28/16
to JsonPath
The expression works fine but returns an array. How do I get the first element in the result array?
$.actions[?(@.failCount)].failCount[0] or $.actions[?(@.failCount)][0].failCount don't work
Reply all
Reply to author
Forward
0 new messages