Check if any value in jsonPath is repeated.

Hey Gus, can someone help me regarding this ? http://stackoverflow.com/questions/40954727/check-if-any-value-in-jsonpath-is-repeated

What is use of this find DSL ? $.book[?(@.author==‘Nigel Rees’)].find(1)

I have a jsonPath as below

{   "book":
        [ 
            { "category": "reference",
              "author": "Nigel Rees",
              "title": "Sayings of the Century",
              "price": 8.95
            },
            { "category": "fiction",
              "author": "Nigel Rees",
              "title": "Sword of Honour",
              "price": 12.99
            }
]}

And Want to check if any author name have got repeated? I tried

$.book[?(@.author=='Nigel Rees')].find(1)

But, it always throws an exception that found nothing, how could I check that the author='Nigel Rees' occurrences i.e author='Nigel Rees' have a two books?

I found something, here http://gatling.io/docs/2.0.0-RC3/http/http_check.html?highlight=transforming#transforming

check(regex("aWord").find(1).exists))

Verifies that there are at least two occurrences of “aWord”, How can I implement it JSON ?

You can try to save your JSONPath result and then try to get its size:
.check(jsonPath("$..book[?(@.author=='Nigel Rees')]").findAll.saveAs("books")) "${books.size()}"

http://gatling.io/docs/2.0.0-RC2/session/expression_el.html

Thanks Nikolay :slight_smile: