JSONPath_Examples_RestAssured
JSONPath_Examples_RestAssured
JSONPath is a syntax for querying JSON data, similar to XPath for XML. In the context of Rest
Assured, JSONPath is used to extract specific pieces of information from a JSON response. It
allows you to traverse the JSON structure, filter data, and retrieve the values you need for your
API tests.
JSON Path is a powerful way to query and extract specific data from JSON documents. In Rest
Assured, JSON Path is used to navigate and extract data from JSON responses efficiently. JSON
Path expressions are akin to XPath expressions used in XML documents.
Rest Assured provides a convenient way to apply JSONPath expressions to a JSON response. It
can be used to assert values, extract data for further use, or perform various other checks on
the response.
JSONPath Syntax Basics
• Root: $ refers to the root of the JSON.
• Dot Notation: Accesses child elements, e.g., $.store.book.
• Bracket Notation: Alternative to dot notation, useful for accessing keys with special
characters or spaces, e.g., $['store']['book'].
• Wildcards: * can be used to match any element, e.g., $..author (all authors).
• Array Indexing: Access specific elements of an array, e.g., $.store.book[0].
• Filters: [?(@.price < 10)] filters items based on a condition.