0
votes

I have to compare two json response as successful response in JMETER.

For example either I will get a response with values,

[
    {
        "id": 423082,
         "createdBy": 10000,
         "createdOn": "03/11/2016 12:04 PM"
    },
    {
         "id": 423083,
         "createdBy": 10001,
         "createdOn": "06/11/2016 12:04 PM"
    }
]

OR I will get an empty json []

Both are successful results for me.

How can I compare these results in Response Assertion or JSON Path Extractor as successful results.

1
improve formattingPaweł Mikołajczuk
how precise you want to be in the case the data is returned? Because simplest solution would be something like \[(\{.*\})*\] - checks whether it's a JSON array with 0 or more objects inside. But it can be as fancy as checking whether date is valid and so on...Kiril S.

1 Answers

0
votes

enter image description hereCreate one regular expression extractor with regex \[(.*?)\]and give some variable name like checkpoint now apply a response assertion and pass ${checkpoint_g0}, so that if your response does not have any value than also it'll check for [] empty json otherwise it'll compare whole response