Need to Extract all data based on condition in jmeter

201 views Asked by At

I got below json as response from HttpRequest of jmeter.

[
    {
        "state": {
            "data": {
                "linearId": {
                    "externalId": null,
                    "id": "1234"
                },
                "Contract": {
                    "Status": {
                        "displayName": "Accepted"
                    },
                    "contractType": "life"
                }
            }
        }
    },
    {
        "state": {
            "data": {
                "linearId": {
                    "externalId": null,
                    "id": "4567"
                },
                "Contract": {
                    "Status": {
                        "displayName": "Rejected"
                    },
                    "contractType": "life"
                }
            }
        }
    },
    {
        "state": {
            "data": {
                "linearId": {
                    "externalId": null,
                    "id": "7890"
                },
                "Contract": {
                    "Status": {
                        "displayName": "Accepted"
                    },
                    "contractType": "life"
                }
            }
        }
    }
]

I need to get all the id's as array where displayName is Accepted which needs to be passed to next threadGroup

I have tried some jsonpath expression. But, Couldn't figure out the expression.

How do I get this?

Thanks in advance.

1

There are 1 answers

1
Dmitri T On BEST ANSWER

I believe the following JsonPath query will do the trick for you:

$..state.data[?(@.Contract.Status.displayName == 'Accepted')].linearId.id

Demo:

enter image description here

More information: