Make Selenium Easy

REST Assured Tutorial 60 – Learn to write JsonPath expressions or JsonPath syntax

Introduction

As a part of the End to End REST Assured Tutorial, in this post, we will learn to learn more JsonPath syntax and expressions.

We have already covered the introduction of JsonPath and creating JsonPath for simple and nested JsonObjects and JsonArrays. You can refer to those posts here:-

What Is JsonPath And How To Create It For Simple And Nested JSON Object?

How To Create JsonPath For Simple And Nested JSON Array?

Prerequisite

As we are using RestAssured which includes JsonPath dependency by default, there is no need to include JsonPath dependency explicitly. I have used the below version of Rest Assured for this post:-

Basic concepts of JsonPath supported by Rest Assured

JsonPath in Rest Assured uses Groovy’s GPath notation and is not to be confused with Jayway’s JsonPath syntax. In simple words there are many JsonPath syntaxes you will see around but all will not be supported by RestAssured JsonPath. In this post, we will see all supported JsonPath syntaxes by Rest Assured.

The root node is represented as a “$” sign. While writing JsonPath in RestAssured we do not need to add a dollar sign. The child node of a JSON object can be represented as a dot (.) or using [<childName>]. We can also use [] to represent a particular index element in a JSON array.

Let’s learn syntaxes with examples rather than theory.

Example Program

Output

You can download/clone the above sample project from here.

You can subscribe to my YouTube channel RetargetCommon to learn from video tutorials.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

Find all Selenium related posts here, all API manual and automation related posts here, and find frequently asked Java Programs here.

Many other topics you can navigate through the menu.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

REST Assured Tutorial 60 – Learn to write JsonPath expressions or JsonPath syntax

by Amod Mahajan time to read: 4 min
0
%d bloggers like this: