JSONPath Flashcards
What is JSONPath?
a query language that helps us in parsing the JSON data, which can be used for validation or assertions in a test.
JSONPath Maven dependency
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
JSONPath operator $
This is the root element and starting point for all path expressions.
JSONPath operator @
This is a filter predicate for the current node.
JSONPath operator *
This is a wildcard operator. It will return all objects regardless of their names or indexes.
..
This searches for the specified name recursively.
.<name></name>
This is used for denoting the child element of the current element by name or index using dots ..
[‘<name>' (, '<name>')]</name></name>
This is used for denoting the child element of the current element by name or index using brackets [ ].
[<number> (, <number>)]</number></number>
This is used for denoting the array index of the element
[start:end]
This is used for slicing the array based on start and end indexes.
[?(<expression>)]</expression>
This is a filter expression and must evaluate to a boolean value.