Check if any value in jsonPath is repeated.

Hey Gus, can someone help me regarding this ?

What is use of this find DSL ? $.book[?(‘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[?('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


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("$[?('Nigel Rees')]").findAll.saveAs("books")) "${books.size()}"

Thanks Nikolay :slight_smile: