1

I want to extract all the serviceItemId's, this object I got it from an external system and I have to verify the contents are correct or not.

The used JSON Object:

[
    [
        {
            "serviceItemId": "SGR40400002",
            "deliveryId": "1",
            "unitOfMeasure": "ORDERS"
        },
        {
            "serviceItemId": "SGR40400003",
            "deliveryId": "2",
            "unitOfMeasure": "ORDERS"
        },
        {
            "serviceItemId": "SGR40400002",
            "deliveryId": "3",
            "unitOfMeasure": "ORDERS"
        }
    ]
]

How do I extract all the serviceItemId's?

1 Answer 1

2

You can do this using JSON Extractor

  1. Add JSON Extractor as a child of the request which returns the above JSON
  2. Configure it as follows:

    enter image description here

  3. That's it, now you have all serviceItemId values extracted into the following JMeter Variables:

    serviceItemId_1=SGR40400002
    serviceItemId_2=SGR40400003
    serviceItemId_3=SGR40400002
    serviceItemId_matchNr=3
    

    enter image description here

  4. You can now verify their values using Response Assertion

    enter image description here

1
  • Sorry I am not clear with the question i think so, the above json payload I am getting from the external system, I am getting this payload via queue I have to verify the contents and I am not going to use this as request so pls tell me how to retrieve the values through script Mar 6, 2019 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.