Rishab Kulkarni
Rishab Kulkarni

Reputation: 1

How to validate JsonPath using com.jayway.jsonpath library

I have the following json object,

{
    "sampleList": [
        {
            "sampleName": "randomSampleName",
            "sampleProperties": [
                {
                    "sampleName": "randomSampleName",
                    "sampleData": {
                        "initialData": {
                            "sampleId": "1122",
                            "list": [
                                {
                                    "type": "0x01",
                                    "value": {
                                        "valueType": "integer",
                                    }
                                },
                                {
                                    "type": "0x02",
                                    "value": {
                                        "valueType": "integer"
                                    }
                                }
                            ],
                            "arguments": {
                                "iv": {
                                    "value": "{{ $.list[?(@.type == 1)][0].value }}",
                                },
                                "value": "{{ $.list[?(@.type == 2)][0].value }}",
                            },
                        }
                    }
                }
            ]
        }
    ]
}

how do I use the jayway.jsonpath library to find what's actually stored by parsing the expression - "value": "{{ $.list[?(@.type == 1)][0].value }}".

With the jsonpath library I am able to extract the above string out, but I'm not sure how to find the actual value which is stored there.

I've tried using the '$', '.', operators to extract the string which is present in my json object in Java code. But I could not find any documentation online which helps me in finding the value of the expression - {{ $.list[?(@.type == 1)][0].value }}

Upvotes: 0

Views: 52

Answers (0)

Related Questions