0

I need to extract specific value from JSON response (or text) with a condition (another JSON value):

I have this response:

{
    "availabilityPercentage": "0.7713",
    "availability": [
        {
            "date": "2021-03-05",
            "estimators": [
                {
                    "skills": [
                        "Non-Driveable"
                    ],
                    "estimatorId": "99999999-0000-0000-9999-000000000002",
                    "timeSlots": [
                        {
                            "timeFrom": "08:00",
                            "isAvailable": false,
                            "timeTo": "08:30",
                            "slot": "MjAyMS0wMy0wNSUwODowMDowMCUwODozMDowMA"
                        },
                        {
                            "timeFrom": "08:30",
                            "isAvailable": true,
                            "timeTo": "09:00",
                            "slot": "MjAyMS0wMy0wNSUwODozMDowMCUwOTowMDowMA"
                        },
                        {
                            "timeFrom": "09:00",
                            "isAvailable": false,
                            "timeTo": "09:30",
                            "slot": "MjAyMS0wMy0wNSUwOTowMDowMCUwOTozMDowMA"
                        }
                        }
                    ]
                }
            ]
        }
    ] }

And I want to extract only "slot" value when "isAvailable" is true.

How can I do it with JMeter?

Thanks in advance.

Regards

2 Answers 2

1

You can use JSON JMESPath Extractor which allows executing arbitrary JMESPath queries which is probably the most powerful way of getting data from JSON responses

Example JMESPath query:

 availability[*].estimators[*].timeSlots[?isAvailable==`true`].slot | [0] | [0]

Demo:

enter image description here

More information: The JMeter JSON JMESPath Extractor and Assertion: A Guide

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Dmitri T that also worked for me.
0

Please try the below, use a JSON extractor and put this condition.

$..[?(@.isAvailable == true)].slot

enter image description here

Also please check your JSON is not formatted correctly

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.