Make Selenium Easy

REST Assured Tutorial 61 – Deserialize Using JsonPath


As a part of the End to End REST Assured Tutorial, in this post, we will learn to deserialize using JsonPath.

Earlier we have seen De-Serialization – JSON Object To Java Object Using Jackson API. The same we can achieve using JsonPath as well.


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:-

Deserialization using JsonPath

We will take a very simple JSON Object and will create a POJO for it.

JSON Object Example

Employee POJO

Converting a Java object to a JSON object is called serialization and the reverse of it is called deserialization. JsonPath class provides a method named “T getObject(String path, Class objectType)” which helps to get the result of an Object path expression as a java Object.

Deserialization example


JSON Array example

Above I used “” and “$” as JSON path string as we have a simple JSON Object. If we have a nested or JSON array then we can write a proper JSON path syntax and deserialize only the result of it.

Suppose we have a JSON array as below:-

If we want to deserialize only the second JSON object from the above JSON array, we can do that as well.

Deserialization example for JSON array


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.

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

A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.

1 thought on “REST Assured Tutorial 61 – Deserialize Using JsonPath

  1. Hi,
    Please could you help me? I don’t know how to deserialize this

    “status”: {
    “timestamp”: “2022-01-18T15:27:20.907Z”,
    “error_code”: 0,
    “error_message”: null,
    “elapsed”: 16,
    “credit_count”: 1,
    “notice”: null
    “data”: [
    “id”: 1,
    “name”: “Bitcoin”,
    “symbol”: “BTC”,
    “slug”: “bitcoin”,
    “rank”: 1,
    “is_active”: 1,
    “first_historical_data”: “2013-04-28T18:47:21.000Z”,
    “last_historical_data”: “2022-01-18T15:19:00.000Z”,
    “platform”: null
    “id”: 1027,
    “name”: “Ethereum”,
    “symbol”: “ETH”,
    “slug”: “ethereum”,
    “rank”: 2,
    “is_active”: 1,
    “first_historical_data”: “2015-08-07T14:49:30.000Z”,
    “last_historical_data”: “2022-01-18T15:19:00.000Z”,
    “platform”: null

    I created POJO class Coin and now have to to populate it. Your example didn’t help me. And I don’t know how to bypass “status”

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.