Extraction from JSON in Rest Assured – JsonPath

HOME

In this tutorial, I will explain how can we extract the body from JSON Response in Rest Assured. This is needed for the assertion of tests. In the previous tutorial, I explained various types of Assertions can be done on JSON Request using Hamcrest.

JsonPath is available at the Central Maven Repository. Maven users add this to the POM.

<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <version>2.9.0</version>
</dependency>

If the project is Gradle, add the below dependency in build.gradle.

 testImplementation 'com.jayway.jsonpath:json-path:2.6.0'

JsonPath expressions can use the dot–notation.

$.store.book[0].title

or the bracket–notation

$['store']['book'][0]['title']
Expression Description
$ The root object or array.
.property Selects the specified property in a parent object.
[‘property’] Selects the specified property in a parent object. Be sure to put single quotes around the property name.Tip: Use this notation if the property name contains special characters such as spaces, or begins with a character other than A..Za..z_.
[n] Selects the n-th element from an array. Indexes are 0-based.
[index1,index2,…] Selects array elements with the specified indexes. Returns a list.
..property Recursive descent: Searches for the specified property name recursively and returns an array of all values with this property name. Always returns a list, even if just one property is found.
* Wildcard selects all elements in an object or an array, regardless of their names or indexes.
[start:end]
[start:]
Selects array elements from the start index and up to, but not including, end index. If end is omitted, selects all elements from start until the end of the array. Returns a list.
[:n] Selects the first n elements of the array. Returns a list.
[-n:] Selects the last n elements of the array. Returns a list.
[?(expression)] Selects all elements in an object or array that match the specified filter. Returns a list.
[(expression)] Script expressions can be used instead of explicit property names or indexes. An example is [(@.length-1)] which selects the last item in an array. Here, length refers to the length of the current array rather than a JSON field named length.
@ Used in filter expressions to refer to the current node being processed.

Below is the sample JSON which I am using for extraction examples. I have saved this file in resources/Payloads as test.json.

{
    "store": {
        "book": [
            {
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            },
            {
                "category": "fiction",
                "author": "Evelyn Waugh",
                "title": "Sword of Honour",
                "price": 12.99
            },
            {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            },
            {
                "category": "fiction",
                "author": "J. R. R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    },
    "expensive": 10
}

To extract all books present in the store:-

String allBooks = JsonPath.read(jsonString, "$..*").toString();
System.out.println("--------------- All books in the store --------------");
System.out.println(allBooks);
import com.jayway.jsonpath.JsonPath;
public class JsonPath_Demo {

    public static void main(String args[]) {

        String jsonString = new String(Files.readAllBytes(Paths.get("src/test/resources/Payloads/test.json")));

        String allBooks = JsonPath.read(jsonString, "$..*").toString();
        System.out.println("--------------- All books in the store --------------");
        System.out.println(allBooks);
    }
}

Below are examples that show how to extract different nodes from a JSON Body. I have used the above JSON Body for these examples.

 // All bicycles in the store
String allBicycles = JsonPath.read(jsonString, "$..bicycle").toString();
System.out.println("--------------- All bicycles in the store ---------------");
System.out.println(allBicycles);

// The number of books
String noOfBooks = JsonPath.read(jsonString, "$..book.length()").toString();
System.out.println("--------------- The number of books ---------------");
System.out.println(noOfBooks);

// The authors of all books
String authors = JsonPath.read(jsonString, "$.store.book[*].author").toString();
System.out.println("--------------- Author of all Books ---------------");
System.out.println(authors);

// All authors
String allAuthors = JsonPath.read(jsonString, "$..author").toString();
System.out.println("--------------- All Authors ---------------");
System.out.println(allAuthors);

// All details of the store
String store = JsonPath.read(jsonString, "$.store.*").toString();
System.out.println("--------------- All details of the store ---------------");
System.out.println(store);

// Price of store
String storePrice = JsonPath.read(jsonString, "$.store..price").toString();
System.out.println("--------------- price of store ---------------");
System.out.println(storePrice);

Below are the examples where I have extracted specific book (nodes) from the JSON body.

// Third book
String thirdBook = JsonPath.read(jsonString, "$..book[2]").toString();
System.out.println("--------------- third book ---------------");
System.out.println(thirdBook);

// first Last Book
String firstLastBook = JsonPath.read(jsonString, "$..book[-1]").toString();
System.out.println("--------------- first Last Book ---------------");
System.out.println(firstLastBook);

// first two Books
String firstTwoBooks = JsonPath.read(jsonString, "$..book[0,1]").toString();
System.out.println("--------------- first Two Books ---------------");
System.out.println(firstTwoBooks);

// books from index 0 (inclusive) until index 2 (exclusive)
String booksRange = JsonPath.read(jsonString, "$..book[:2]").toString();
System.out.println("--------------- books from index 0 (inclusive) until index 2 (exclusive) ---------------");
System.out.println(booksRange);

// All books from index 1 (inclusive) until index 2 (exclusive)
String booksRange1 = JsonPath.read(jsonString, "$..book[1:2]").toString();
System.out.println("------------ All books from index 1 (inclusive) until index 2 (exclusive) -----------");
System.out.println(booksRange1);

// Book number one from tail
String bottomBook = JsonPath.read(jsonString, "$..book[1:]").toString();
System.out.println("--------------- Book number one from tail ---------------");
System.out.println(bottomBook);

Filters are logical expressions used to filter arrays. Below are examples of a JSONPath expression with the filters.

// All books in store expensive than 10
String expensiveBook = JsonPath.read(jsonString, "$.store.book[?(@.price > 10)]").toString();
System.out.println("--------------- All books in store costlier than 10 ---------------");
System.out.println(expensiveBook);

// All books in store that are not "expensive"
String notExpensiveBook = JsonPath.read(jsonString, "$..book[?(@.price <= $['expensive'])]").toString();
System.out.println("--------------- All books in store that are not expensive ---------------");
System.out.println(notExpensiveBook);

// All books in store that are equal to price 8.95
String comparePrice = JsonPath.read(jsonString, "$.store.book[?(@.price == 8.95)]").toString();
System.out.println("--------------- All books in store that are not expensive ---------------");
System.out.println(comparePrice);

// All books matching regex (ignore case)
String regxExample = JsonPath.read(jsonString, "$..book[?(@.author =~ /.*REES/i)]").toString();
System.out.println("--------------- All books matching regex (ignore case) ---------------");
System.out.println(regxExample);

// All books with price equal to mentioned list of prices
String priceList = JsonPath.read(jsonString, "$..book[?(@.price in ['12.99', '8.99'])]").toString();
System.out.println("--------------- All books with price equal to mentioned list of prices ---------------");
System.out.println(priceList);

// All books with price NOT equal to mentioned list of prices
String excludePriceList = JsonPath.read(jsonString, "$..book[?(@.price nin ['12.99', '8.99'])]").toString();
System.out.println("---------- All books with price NOT equal to mentioned list of prices ---------");
System.out.println(excludePriceList);

// All books with specified substring (case-sensitive)
String substringExample = JsonPath.read(jsonString, "$..book[?(@.author contains 'Melville')]").toString();
System.out.println("--------------- All books with specified substring (case-sensitive) ---------------");
System.out.println(substringExample);

// All books with an ISBN number
String specificBook = JsonPath.read(jsonString, "$..book[?(@.isbn)]").toString();
System.out.println("--------------- All books with an ISBN number ---------------");
System.out.println(specificBook);

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

9 thoughts on “Extraction from JSON in Rest Assured – JsonPath

  1. hi

    thanks fo the tutorial

    if i have multiple array .if i want to get data from all the array . how following code works.please reply

    @ your code

    String allBooks = JsonPath.read(jsonString, “$..*”).toString();
    System.out.println(“————— All books in the store ————–“);
    System.out.println(allBooks);

    {
    “message”: “Success”,
    “data”: {
    “mst_oem”: [
    {
    “id”: 1,
    “name”: “Google”,
    “code”: “GL”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 2,
    “name”: “Apple”,
    “code”: “APL”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 3,
    “name”: “Redmi”,
    “code”: “RDI”,
    “is_active”: 1,
    “created_at”: “2022-10-21T11:28:07.000Z”,
    “modified_at”: “2022-10-21T11:28:07.000Z”
    },
    {
    “id”: 4,
    “name”: “IQOO”,
    “code”: “IQ”,
    “is_active”: 1,
    “created_at”: “2022-12-16T11:56:13.000Z”,
    “modified_at”: “2022-12-16T11:56:13.000Z”
    },
    {
    “id”: 5,
    “name”: “VIVO”,
    “code”: “VI”,
    “is_active”: 1,
    “created_at”: “2023-04-09T16:32:23.000Z”,
    “modified_at”: “2023-04-09T16:32:23.000Z”
    },
    {
    “id”: 6,
    “name”: “LG”,
    “code”: “LGGG”,
    “is_active”: 1,
    “created_at”: “2022-05-21T10:11:28.000Z”,
    “modified_at”: “2022-05-21T10:54:11.000Z”
    },
    {
    “id”: 7,
    “name”: “SAMSUNG”,
    “code”: “SAMG”,
    “is_active”: 1,
    “created_at”: “2022-08-18T16:53:16.000Z”,
    “modified_at”: “2022-08-18T16:53:16.000Z”
    },
    {
    “id”: 8,
    “name”: “ONEPLUS”,
    “code”: “ONEPLUS”,
    “is_active”: 1,
    “created_at”: “2022-10-10T04:57:15.000Z”,
    “modified_at”: “2022-10-10T04:57:15.000Z”
    },
    {
    “id”: 9,
    “name”: “NOKIA”,
    “code”: “NOK”,
    “is_active”: 1,
    “created_at”: “2022-12-12T15:44:00.000Z”,
    “modified_at”: “2022-12-12T15:44:00.000Z”
    },
    {
    “id”: 10,
    “name”: “ORANGE”,
    “code”: “ORA”,
    “is_active”: 1,
    “created_at”: “2022-12-13T10:56:03.000Z”,
    “modified_at”: “2022-12-13T10:58:46.000Z”
    },
    {
    “id”: 11,
    “name”: “DYSON”,
    “code”: “DYS”,
    “is_active”: 1,
    “created_at”: “2022-12-15T15:35:39.000Z”,
    “modified_at”: “2022-12-15T15:35:39.000Z”
    },
    {
    “id”: 12,
    “name”: “RealmeX”,
    “code”: “RX”,
    “is_active”: 1,
    “created_at”: “2022-12-19T15:04:55.000Z”,
    “modified_at”: “2022-12-19T15:04:55.000Z”
    },
    {
    “id”: 19,
    “name”: “XYZ”,
    “code”: “xyz”,
    “is_active”: 1,
    “created_at”: “2022-12-15T15:35:39.000Z”,
    “modified_at”: “2022-12-15T15:35:39.000Z”
    },
    {
    “id”: 23,
    “name”: “OPPO”,
    “code”: “OPPO”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:40:45.000Z”,
    “modified_at”: “2022-12-19T20:40:45.000Z”
    },
    {
    “id”: 24,
    “name”: “TECNO”,
    “code”: “TEC”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 43,
    “name”: “Test1”,
    “code”: “GLT”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 44,
    “name”: “testPk1”,
    “code”: “PK1”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 48,
    “name”: “testPk1”,
    “code”: “PK1”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 65,
    “name”: “testPk1”,
    “code”: “PK1”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 71,
    “name”: “Test”,
    “code”: “Test”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-09T20:42:09.000Z”
    },
    {
    “id”: 72,
    “name”: “Test”,
    “code”: “Test”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-09T20:42:09.000Z”
    },
    {
    “id”: 83,
    “name”: “Test”,
    “code”: “Test”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-09T20:42:09.000Z”
    },
    {
    “id”: 84,
    “name”: “Test”,
    “code”: “Test”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-09T20:42:09.000Z”
    },
    {
    “id”: 85,
    “name”: “Test”,
    “code”: “Test”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-09T20:42:09.000Z”
    },
    {
    “id”: 93,
    “name”: “sam”,
    “code”: “Caleb”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 94,
    “name”: “sam”,
    “code”: “Caleb”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 107,
    “name”: “TT”,
    “code”: “T”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 108,
    “name”: “TT”,
    “code”: “T”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2021-10-26T08:24:17.000Z”
    },
    {
    “id”: 116,
    “name”: “testPk1”,
    “code”: “PK1”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 117,
    “name”: “testPk1”,
    “code”: “PK1”,
    “is_active”: 1,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 119,
    “name”: “BASH”,
    “code”: “BAS”,
    “is_active”: 1,
    “created_at”: “2023-01-25T14:49:26.000Z”,
    “modified_at”: “2023-01-25T14:49:26.000Z”
    },
    {
    “id”: 149,
    “name”: “RealMe”,
    “code”: “Pro”,
    “is_active”: 1,
    “created_at”: “2023-05-05T09:25:19.000Z”,
    “modified_at”: “2023-05-05T09:25:19.000Z”
    },
    {
    “id”: 150,
    “name”: “VIVO”,
    “code”: “V1_Max”,
    “is_active”: 1,
    “created_at”: “2023-05-05T09:25:19.000Z”,
    “modified_at”: “2023-05-05T09:25:19.000Z”
    },
    {
    “id”: 151,
    “name”: “RealMe”,
    “code”: “Pro”,
    “is_active”: 1,
    “created_at”: “2023-05-05T09:25:19.000Z”,
    “modified_at”: “2023-05-05T09:25:19.000Z”
    },
    {
    “id”: 152,
    “name”: “VIVO”,
    “code”: “V1_Max”,
    “is_active”: 1,
    “created_at”: “2023-05-05T09:25:19.000Z”,
    “modified_at”: “2023-05-05T09:25:19.000Z”
    }
    ],
    “mst_model”: [
    {
    “id”: 1,
    “name”: “Nexus 2 blue”,
    “code”: “NX2BL”,
    “mst_product_id”: 1,
    “is_active”: 1,
    “created_at”: “2021-10-29T19:28:00.000Z”,
    “modified_at”: “2021-10-29T19:28:00.000Z”
    },
    {
    “id”: 2,
    “name”: “gallexy”,
    “code”: “gl”,
    “mst_product_id”: 1,
    “is_active”: 1,
    “created_at”: “2022-06-10T07:18:03.000Z”,
    “modified_at”: “2022-06-10T07:18:03.000Z”
    },
    {
    “id”: 3,
    “name”: “Iphone 11”,
    “code”: “ip11”,
    “mst_product_id”: 3,
    “is_active”: 1,
    “created_at”: “2022-08-18T16:59:27.000Z”,
    “modified_at”: “2022-08-18T17:00:31.000Z”
    },
    {
    “id”: 4,
    “name”: “MI”,
    “code”: “mi”,
    “mst_product_id”: 5,
    “is_active”: 1,
    “created_at”: “2022-10-21T12:14:13.000Z”,
    “modified_at”: “2022-10-21T12:14:13.000Z”
    },
    {
    “id”: 5,
    “name”: “WIFI”,
    “code”: “NO-WIFI”,
    “mst_product_id”: 6,
    “is_active”: 1,
    “created_at”: “2022-12-12T15:49:09.000Z”,
    “modified_at”: “2022-12-12T15:49:09.000Z”
    },
    {
    “id”: 6,
    “name”: “ORA-111”,
    “code”: “111”,
    “mst_product_id”: 7,
    “is_active”: 1,
    “created_at”: “2022-12-13T11:00:23.000Z”,
    “modified_at”: “2022-12-13T11:00:23.000Z”
    },
    {
    “id”: 7,
    “name”: “NEO-3T”,
    “code”: “3T”,
    “mst_product_id”: 8,
    “is_active”: 1,
    “created_at”: “2022-12-16T14:40:32.000Z”,
    “modified_at”: “2022-12-16T14:40:32.000Z”
    },
    {
    “id”: 8,
    “name”: “RealmeX”,
    “code”: “R”,
    “mst_product_id”: 9,
    “is_active”: 1,
    “created_at”: “2022-12-19T17:27:43.000Z”,
    “modified_at”: “2022-12-19T17:27:43.000Z”
    }
    ],
    “mst_action_status”: [
    {
    “id”: 1,
    “name”: “Job Creation”,
    “code”: “JBC”,
    “description”: “Job Creation”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 2,
    “name”: “Pending For Job Assignment”,
    “code”: “PJFA”,
    “description”: “Pending For Job Assignment”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 3,
    “name”: “Pending For Repair”,
    “code”: “PFR”,
    “description”: “Pending For Repair”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 4,
    “name”: “Pending For QC”,
    “code”: “PFQC”,
    “description”: “Pending For QC”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 5,
    “name”: “Pending for Delivery”,
    “code”: “PDL”,
    “description”: “Pending for Delivery”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-12-20T08:00:39.000Z”
    },
    {
    “id”: 6,
    “name”: “Delivered to customer”,
    “code”: “DC”,
    “description”: “Delivered to customer”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-12-20T08:01:48.000Z”
    },
    {
    “id”: 7,
    “name”: “QC Rejected”,
    “code”: “QCR”,
    “description”: “QC Rejected”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 8,
    “name”: “Quatation Raised”,
    “code”: “QR”,
    “description”: “Quatation Raised”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 9,
    “name”: “Pending For Payment”,
    “code”: “PFP”,
    “description”: “Pending For Payment”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 10,
    “name”: “Payment Is Done”,
    “code”: “PD”,
    “description”: “Payment Is Done”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 11,
    “name”: “Job Closed Successfully”,
    “code”: “JC”,
    “description”: “Job Closed Successfully”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 12,
    “name”: “Assigned to FST – Inbound”,
    “code”: “AFI”,
    “description”: “Assigned to FST – Inbound”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 13,
    “name”: “Assigned to FST – Outbound”,
    “code”: “AFO”,
    “description”: “Assigned to FST – Outbound”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 14,
    “name”: “Begin Journey”,
    “code”: “BJY”,
    “description”: “Begin Journey”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 15,
    “name”: “Submitted To FD”,
    “code”: “SFD”,
    “description”: “Submitted To FD”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    },
    {
    “id”: 16,
    “name”: “Collected At FD”,
    “code”: “CFD”,
    “description”: “Collected At FD”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:48:23.000Z”,
    “modified_at”: “2021-10-26T08:48:23.000Z”
    }
    ],
    “mst_warrenty_status”: [
    {
    “id”: 1,
    “name”: “In Warrenty”,
    “code”: “IW”,
    “description”: “In Warrenty”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:26:04.000Z”,
    “modified_at”: “2021-10-26T08:26:04.000Z”
    },
    {
    “id”: 2,
    “name”: “Out Of Warrenty”,
    “code”: “OOW”,
    “description”: “Out Of Warrenty”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:26:04.000Z”,
    “modified_at”: “2021-10-26T08:26:04.000Z”
    }
    ],
    “mst_platform”: [
    {
    “id”: 1,
    “name”: “FST”,
    “code”: “FST”,
    “description”: “Field technician will go to customer’s house”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:37:12.000Z”,
    “modified_at”: “2021-10-26T08:37:12.000Z”
    },
    {
    “id”: 2,
    “name”: “Front Desk”,
    “code”: “FD”,
    “description”: “Customer will come to service center to submit his device”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:37:12.000Z”,
    “modified_at”: “2021-10-26T08:37:12.000Z”
    }
    ],
    “mst_product”: [
    {
    “id”: 1,
    “name”: “Nexus 2”,
    “code”: “NX2”,
    “mst_oem_id”: 1,
    “is_active”: 1,
    “created_at”: “2021-10-29T19:27:21.000Z”,
    “modified_at”: “2021-10-29T19:27:21.000Z”
    },
    {
    “id”: 2,
    “name”: “Pixel”,
    “code”: “gl”,
    “mst_oem_id”: 1,
    “is_active”: 1,
    “created_at”: “2022-06-10T07:16:57.000Z”,
    “modified_at”: “2022-08-18T16:55:02.000Z”
    },
    {
    “id”: 3,
    “name”: “IPhone”,
    “code”: “ip”,
    “mst_oem_id”: 2,
    “is_active”: 1,
    “created_at”: “2022-08-18T16:56:15.000Z”,
    “modified_at”: “2022-08-18T16:57:20.000Z”
    },
    {
    “id”: 4,
    “name”: “Galaxy Series”,
    “code”: “GAL”,
    “mst_oem_id”: 7,
    “is_active”: 1,
    “created_at”: “2022-08-18T16:57:54.000Z”,
    “modified_at”: “2022-08-18T16:57:54.000Z”
    },
    {
    “id”: 5,
    “name”: “redmi”,
    “code”: “mi”,
    “mst_oem_id”: 3,
    “is_active”: 1,
    “created_at”: “2022-10-21T12:12:16.000Z”,
    “modified_at”: “2022-10-21T12:12:16.000Z”
    },
    {
    “id”: 6,
    “name”: “NOKIA-T20”,
    “code”: “N-T20”,
    “mst_oem_id”: 9,
    “is_active”: 1,
    “created_at”: “2022-12-12T15:47:27.000Z”,
    “modified_at”: “2022-12-12T15:47:27.000Z”
    },
    {
    “id”: 7,
    “name”: “ORANGE-Gold”,
    “code”: “ORA-G”,
    “mst_oem_id”: 10,
    “is_active”: 1,
    “created_at”: “2022-12-13T10:58:31.000Z”,
    “modified_at”: “2022-12-13T10:58:31.000Z”
    },
    {
    “id”: 8,
    “name”: “IQOO-NEO”,
    “code”: “I-NEO”,
    “mst_oem_id”: 4,
    “is_active”: 1,
    “created_at”: “2022-12-16T14:20:16.000Z”,
    “modified_at”: “2022-12-16T14:20:16.000Z”
    },
    {
    “id”: 9,
    “name”: “RealmeX”,
    “code”: “RX”,
    “mst_oem_id”: 12,
    “is_active”: 1,
    “created_at”: “2022-12-19T14:59:57.000Z”,
    “modified_at”: “2022-12-19T15:08:47.000Z”
    },
    {
    “id”: 10,
    “name”: “PkProdUpdated”,
    “code”: “PK1”,
    “mst_oem_id”: 48,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:24:17.000Z”,
    “modified_at”: “2023-01-03T14:39:57.000Z”
    },
    {
    “id”: 27,
    “name”: “BASH_T20”,
    “code”: “T20”,
    “mst_oem_id”: 119,
    “is_active”: 1,
    “created_at”: “2023-01-25T14:59:50.000Z”,
    “modified_at”: “2023-01-25T14:59:50.000Z”
    }
    ],
    “mst_role”: [
    {
    “id”: 1,
    “name”: “Engineer”,
    “code”: “ENG”,
    “description”: “Engineer”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2021-10-26T08:39:48.000Z”
    },
    {
    “id”: 2,
    “name”: “Supervisor”,
    “code”: “SPV”,
    “description”: “Supervisor”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2021-10-26T08:39:48.000Z”
    },
    {
    “id”: 3,
    “name”: “FST”,
    “code”: “FST”,
    “description”: “Field Service Technician”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2021-10-26T08:39:48.000Z”
    },
    {
    “id”: 4,
    “name”: “QC”,
    “code”: “QC”,
    “description”: “Quality check”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2021-10-26T08:39:48.000Z”
    },
    {
    “id”: 5,
    “name”: “FrontDesk”,
    “code”: “FD”,
    “description”: “Front Desk”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2022-01-04T15:16:54.000Z”
    },
    {
    “id”: 6,
    “name”: “Callcenter”,
    “code”: “CC”,
    “description”: “Callcenter”,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:39:48.000Z”,
    “modified_at”: “2022-01-04T15:16:54.000Z”
    }
    ],
    “mst_service_location”: [
    {
    “id”: 1,
    “name”: “Service Center A”,
    “code”: “B2X”,
    “mobile_number”: “8877667788”,
    “email_id”: “servicecentera@gmail.com”,
    “address”: “M.G. Road, Andheri(E)”,
    “pincode”: 400075,
    “country”: “India”,
    “gstin”: “22AAAAA0000A1”,
    “is_repair_line_engineer”: 1,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:30:50.000Z”,
    “modified_at”: “2022-04-03T16:09:58.000Z”
    },
    {
    “id”: 2,
    “name”: “Service Center B”,
    “code”: “SFY”,
    “mobile_number”: “8877667789”,
    “email_id”: “servicecenterb@gmail.com”,
    “address”: “M.G. Road, Andheri(E)”,
    “pincode”: 400606,
    “country”: “India”,
    “gstin”: “22AAAAA0000B2”,
    “is_repair_line_engineer”: 1,
    “is_active”: 1,
    “created_at”: “2021-10-26T08:30:50.000Z”,
    “modified_at”: “2022-04-03T16:09:59.000Z”
    },
    {
    “id”: 3,
    “name”: “Service Centre C”,
    “code”: “PKC”,
    “mobile_number”: “8877667790”,
    “email_id”: “servicecenterpk@gmail.com”,
    “address”: “Srinagar,Kashmir(A)”,
    “pincode”: 577432,
    “country”: “India”,
    “gstin”: “22AAAAA0000C3”,
    “is_repair_line_engineer”: 1,
    “is_active”: 1,
    “created_at”: “2022-12-13T11:05:47.000Z”,
    “modified_at”: “2022-12-13T11:05:47.000Z”
    }
    ],
    “mst_problem”: [
    {
    “id”: 1,
    “name”: “Smartphone is running slow”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 2,
    “name”: “Poor battery life”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 3,
    “name”: “Phone or app crashes”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 4,
    “name”: “Sync issue”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 5,
    “name”: “MicroSD card is not working on your phone”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 6,
    “name”: “Overheating”,
    “created_at”: “2022-01-08T10:07:18.000Z”,
    “modified_at”: “2022-01-08T10:07:18.000Z”
    },
    {
    “id”: 7,
    “name”: “Connecting problem with Bluetooth, Wifi, Cellular network”,
    “created_at”: “2022-01-08T10:07:19.000Z”,
    “modified_at”: “2022-01-08T10:07:19.000Z”
    },
    {
    “id”: 8,
    “name”: “Cracked screen”,
    “created_at”: “2022-01-08T10:07:19.000Z”,
    “modified_at”: “2022-01-08T10:07:19.000Z”
    },
    {
    “id”: 9,
    “name”: “Other”,
    “created_at”: “2022-01-08T10:07:19.000Z”,
    “modified_at”: “2022-01-08T10:07:19.000Z”
    },
    {
    “id”: 10,
    “name”: “Camera issue”,
    “created_at”: “2022-06-13T15:01:02.000Z”,
    “modified_at”: “2022-06-13T15:01:02.000Z”
    },
    {
    “id”: 11,
    “name”: “Charger Not Working”,
    “created_at”: “2022-08-14T12:38:04.000Z”,
    “modified_at”: “2022-08-14T12:38:04.000Z”
    },
    {
    “id”: 12,
    “name”: ” Software Booting Issue “,
    “created_at”: “2022-08-14T13:03:08.000Z”,
    “modified_at”: “2022-08-14T13:03:08.000Z”
    },
    {
    “id”: 15,
    “name”: “Head Phone Jack not working”,
    “created_at”: “2022-06-16T15:22:18.000Z”,
    “modified_at”: “2022-06-16T15:22:18.000Z”
    },
    {
    “id”: 16,
    “name”: “Head Phone issue”,
    “created_at”: “2022-06-16T15:27:47.000Z”,
    “modified_at”: “2022-06-16T15:27:47.000Z”
    },
    {
    “id”: 17,
    “name”: “Random Problem”,
    “created_at”: “2022-07-11T02:56:01.000Z”,
    “modified_at”: “2022-07-11T02:56:01.000Z”
    },
    {
    “id”: 19,
    “name”: “Front camera not working”,
    “created_at”: “2022-07-13T17:50:54.000Z”,
    “modified_at”: “2022-07-13T17:50:54.000Z”
    },
    {
    “id”: 20,
    “name”: “Battery issue”,
    “created_at”: “2022-07-13T17:51:47.000Z”,
    “modified_at”: “2022-07-13T17:51:47.000Z”
    },
    {
    “id”: 22,
    “name”: “Screen display issue”,
    “created_at”: “2022-08-29T11:09:24.000Z”,
    “modified_at”: “2022-08-29T11:09:24.000Z”
    },
    {
    “id”: 24,
    “name”: “Apps Not Downloading”,
    “created_at”: “2022-08-29T12:10:34.000Z”,
    “modified_at”: “2022-08-29T12:10:34.000Z”
    },
    {
    “id”: 26,
    “name”: “Unresponsive screen”,
    “created_at”: “2022-09-19T10:03:08.000Z”,
    “modified_at”: “2022-09-19T10:03:08.000Z”
    },
    {
    “id”: 27,
    “name”: “Blue Screen Error”,
    “created_at”: “2022-12-13T11:01:48.000Z”,
    “modified_at”: “2022-12-13T11:01:48.000Z”
    },
    {
    “id”: 28,
    “name”: “PK Test Prob1”,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    },
    {
    “id”: 29,
    “name”: “PK Test Prob1”,
    “created_at”: “2022-12-19T20:42:09.000Z”,
    “modified_at”: “2022-12-19T20:42:09.000Z”
    }
    ],
    “map_fst_pincode”: [
    {
    “pincode”: 100011,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    },
    {
    “pincode”: 100012,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    },
    {
    “pincode”: 100013,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    },
    {
    “pincode”: 100014,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    },
    {
    “pincode”: 100015,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    },
    {
    “pincode”: 200011,
    “mst_service_location_id”: 2,
    “mst_service_location_name”: “Service Center B”
    },
    {
    “pincode”: 200012,
    “mst_service_location_id”: 2,
    “mst_service_location_name”: “Service Center B”
    },
    {
    “pincode”: 200013,
    “mst_service_location_id”: 2,
    “mst_service_location_name”: “Service Center B”
    },
    {
    “pincode”: 200014,
    “mst_service_location_id”: 2,
    “mst_service_location_name”: “Service Center B”
    },
    {
    “pincode”: 200015,
    “mst_service_location_id”: 2,
    “mst_service_location_name”: “Service Center B”
    },
    {
    “pincode”: 400065,
    “mst_service_location_id”: 1,
    “mst_service_location_name”: “Service Center A”
    }
    ]
    }
    }

    Like

  2. this line error showing

    import com.jayway.jsonpath.JsonPath;

    String allBooks = JsonPath.read(jsonString, "$..*").toString();

    using this depenency

    <!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path --> <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> <version>2.9.0</version> </dependency>

    Like

Leave a reply to vibssingh Cancel reply