Forum Discussion

WillJones's avatar
WillJones
New Contributor
9 years ago

JsonPath count of embedded node

"Hi I am trying to count the occurences of an embedded node using Json Path Count assertion.

My Json response looks something like this..

{
"logs":[{"logId" : 1234,
            "childLogResponse": [ {"logId": 3085031}]
          }]
}

 

How do I count the number of childLogResponse or match that the childLogResponse logId is a certain ID?

In my JSONPath Expression if I type "logs" and hit Select from current it returns an expected Result 1. If I type "childLogResponse" it returns No match in current response.

If I try "logs.childLogResponse" or "$.logs.childLogResponse" it returns Invalid JsonPath expression.

Many thanks in advance for any help.