Search⌘ K

JSONPath Library

Explore how to use the JSONPath library to parse JSON data efficiently within REST API test automation. This lesson covers core JSONPath operators, dependency setup for Gradle and Maven projects, and practical examples of JSON parsing for validation and assertions in Java. By mastering JSONPath, you can enhance your ability to extract and verify data from API responses.

What is JSONPath?

JSONPath is a query language that helps us in parsing the JSON data, which can be used for validation or assertions in a test.

JSONPath dependency

To use JSONPath, we have to include its dependency on our project.

Gradle

For a Gradle project, add the following dependency in build.gradle:

compile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'

Maven

For a Maven project, add the following dependency in the pom.xml file:

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
   
...