Extracting all of field X from an array of objects in JSON

I have a service that is returning JSON in the format of:

[{“foo”:“bar”},…]

I want to do an extract of all of the values of “foo”. I tried this:

.check( jsonPath( “[*].foo” ).findAll.optional.saveAs( “allFoo” ) )

But that doesn’t work. Can someone enlighten me with the right syntax that will do the job, or point me to the documentation that clearly shows me the right syntax for that use case?

Thank you much!

I was SO close! :slight_smile:

.check( jsonPath( “$[*].foo” ).findAll.optional.saveAs( “allFoo” ) )

Does the trick!

Yep, you always need the $ root.