# Strangeness with jsonPath

**URL:** https://community.gatling.io/t/strangeness-with-jsonpath/1519
**Category:** Gatling (Open-Source)
**Created:** [October 8, 2014, 11:31pm UTC](https://community.gatling.io/t/strangeness-with-jsonpath/1519 "2014-10-08T23:31:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)
#### Post date: [October 8, 2014, 11:31pm UTC](https://community.gatling.io/t/strangeness-with-jsonpath/1519/1 "2014-10-08T23:31:17Z")

</div>

I created a test file on my local apache server with the following contents:

{“result”:[{“id”:1,“name”:“one”},{“id”:2,“name”:“two”},{“id”:3,“name”:“three”}]}

Then I test it like so:

`  
exec(  
http( “fetch” )  
.get( “[http://localhost/data.json](http://localhost/data.json)” )  
.check( jsonPath( “$” ).saveAs( “DATA” ) )  
.check( jsonPath( “$.result[\*]” ).optional.saveAs( “LIST” ) )  
)  
.exec( session =\> {  
println( "DATA = " + session(“DATA”).as[String] )  
println( "LIST = " + session(“LIST”).as[String] )  
session  
})

`

The output looks like this:

`  
DATA = {“result”:[{“id”:1,“name”:“one”},{“id”:2,“name”:“two”},{“id”:3,“name”:“three”}]}  
LIST = {“id”:1,“name”:“one”}

`

I expected it to give me a list, not just the first element. I’ve used this feature before, but suddenly it appears broken, and I don’t think it’s broken in Gatling. I’ve tried varying a bunch of things, trying to figure out what is going on, but I’m not having any luck.

1. Can you recreate the behavior I am seeing?

2. Any ideas what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)
#### Post date: [October 8, 2014, 11:38pm UTC](https://community.gatling.io/t/strangeness-with-jsonpath/1519/2 "2014-10-08T23:38:47Z")

</div>

Just like a regex, JsonPath can indeed capture multiple occurrences. But then, the default check cardinality is find: [http://gatling.io/docs/2.0.0/http/http\_check.html#multiple-results](http://gatling.io/docs/2.0.0/http/http_check.html#multiple-results)

if you want all the results, use findAll

---

<div class="post-metadata">

### Author: ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)
#### Post date: [October 9, 2014, 12:21pm UTC](https://community.gatling.io/t/strangeness-with-jsonpath/1519/3 "2014-10-09T12:21:56Z")

</div>

I knew I was doing something wrong! Thanks, sorry to bug you.
